php_beginner_83 Posted November 25, 2009 Share Posted November 25, 2009 Hi All I'm trying to create a multidimensional array using a while loop but it's not working. When I try and print out the contents of the array, it's empty. Does anyone have any ideas what I'm doing wrong??? Thanks in advance $counter = 0; $myarray = array(); while($counter <= 5) { $myarray = array($counter, $counter + 1, $counter + 2); $counter ++; } Quote Link to comment Share on other sites More sharing options...
Yesideez Posted November 25, 2009 Share Posted November 25, 2009 Not sure if this will work as it's off the top of my head... $arr=array(); for ($i=0;$i<5;++$i) { $arr[]=array(); } var_dump($arr); Is that what you're after? Quote Link to comment Share on other sites More sharing options...
php_beginner_83 Posted November 25, 2009 Author Share Posted November 25, 2009 Thanks Yesideez that did the trick Who would of thought just a wee set of square brackets would make the difference Quote Link to comment Share on other sites More sharing options...
php_beginner_83 Posted November 25, 2009 Author Share Posted November 25, 2009 I would make this as solved but I cant find the button anyway :S Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.