Access a variable using a counter as part of the variable name

前端 未结 5 1966
清歌不尽
清歌不尽 2021-01-29 08:52

I tried to do somthing like that:

$cat1 = array(\'hello\', \'everyone\');
$cat = array(\'bye\', \'everyone\');

for($index = 0; $index < 2; $index++) {
echo $         


        
5条回答
  •  梦谈多话
    2021-01-29 08:58

    You can't reference $index like that, it isn't an array.

    echo $cat[$index];
    

    is what you want to do.

提交回复
热议问题