Add to an 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
User avatar
SmokyBarnable
Forum Contributor
Posts: 105
Joined: Wed Nov 01, 2006 5:44 pm

Add to an array

Post by SmokyBarnable »

I have this array

Code: Select all

$array=array('a' => 1);
I want to add 'b' => 2 to the array but I don't see how to do it.

I tried

Code: Select all

array_push():
but it doesn't let me specify a key?
Z3RO21
Forum Contributor
Posts: 130
Joined: Thu Aug 17, 2006 8:59 am

Post by Z3RO21 »

Code: Select all

$array['b'] = 2;
User avatar
SmokyBarnable
Forum Contributor
Posts: 105
Joined: Wed Nov 01, 2006 5:44 pm

Post by SmokyBarnable »

:o
Post Reply