chiprivers Posted February 20, 2007 Share Posted February 20, 2007 With a noraml array, I understand that you can declare it in either of the following ways: $name = array( list array values seperated by comas... ); or $name[] = value; I am trying to use two-dimensional arrays and all the references tell you to do it like this: $name = array ( $name = array( values in here), $name = array( values in here ) ); but I was wondering if you should be able to do it like this: $name[$x][$y] = value; I have tried it but can't get it to work?? Link to comment https://forums.phpfreaks.com/topic/39307-solved-multidimensional-arrays/ Share on other sites More sharing options...
dustinnoe Posted February 20, 2007 Share Posted February 20, 2007 you may need to create an instance of the top level array. $name[$x]; $name[$x][$y]; I have never tried what you are doing but this may help. Link to comment https://forums.phpfreaks.com/topic/39307-solved-multidimensional-arrays/#findComment-189495 Share on other sites More sharing options...
printf Posted February 20, 2007 Share Posted February 20, 2007 Simple example... <?php $out = array (); for ( $i = 0; $i < 10; $i += 1 ) { $out[$i] = array (); for ( $j = 0; $j < 10; $j += 1 ) { $out[$i][$j] = $j; } } print_r ( $out ); ?> Link to comment https://forums.phpfreaks.com/topic/39307-solved-multidimensional-arrays/#findComment-189499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.