php - The second dimension in multi-dimension array never reached, why? -
php - The second dimension in multi-dimension array never reached, why? -
can explain me why code not work:
<?php for($i = 0; $i < 3; $i++) { for($j = 0; $j < 3; $j++) { $arr[$i][$j] = $i.$j; } } foreach ($arr $key => $value) { foreach ($value $key2 => $value2){ // line 8 = error echo $key." ".$key2."<br />"; } } ?>
i error:
warning: invalid argument supplied foreach() in c:\wamp\www\script\index.php on line 8
i cannot understand why error. array $arr should initiated values in both dimensions. right?
i've tried it, , got output wamp 2.2:
0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2
are using latest wamp? seek downloading , installing new one.
php multidimensional-array
Comments
Post a Comment