climbjm Posted December 31, 2006 Share Posted December 31, 2006 if I have an array that I have created and I want to push data to it.... anyone have an idea as to how to do that?example:[code]$name = "bob";$age = 21;// I want to push the info so the first Col is the name and the second Col is the age, I cant use a db.$personArray = array();array_push($personArray,<this is where i am lost>);[/code]Any ideas?http://us3.php.net/manual/en/function.array-push.php I've tried looking here, but I didn't see it. Quote Link to comment https://forums.phpfreaks.com/topic/32368-array_push-with-2d-arrays/ Share on other sites More sharing options...
Millar Posted December 31, 2006 Share Posted December 31, 2006 Couldn't you just use this?[code]$name = "bob";$age = 21;// I want to push the info so the first Col is the name and the second Col is the age, I cant use a db.$personArray = array();$personArray[ $name ] = $age;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32368-array_push-with-2d-arrays/#findComment-150311 Share on other sites More sharing options...
sasa Posted December 31, 2006 Share Posted December 31, 2006 or[code]array_push($personArray, array('name'=>$name,'age'=>$age));[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32368-array_push-with-2d-arrays/#findComment-150327 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.