Can array_push be used to push onto an associative array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Can array_push be used to push onto an associative array?

Post by impulse() »

My array is empty at the moment but I want results from a DB to be pushed onto the end of it using http://uk.php.net/manual/en/function.array-push.php?

If not how is this possible another way?


Regards,
Last edited by impulse() on Tue May 22, 2007 12:28 pm, edited 1 time in total.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Sorry, I realised I was being silly as soon as I posted this.

This is what I was looking to do (no need for array_push).

Code: Select all

while ($res = mysql_fetch_array($queryData))
  $productsData[$res['groupID']] = $res['groupName'];
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That's not even a 3D array. It's a linear, associative array.
Post Reply