By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

appending to an associate array

P: n/a
Hello:

How can I append a new key-value pair to an associative array?

Thanks,

Ken
Jan 19 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em...@address.comwrote:
How can I append a new key-value pair to an associative array?
Just add it:
$foo = array( 'foo' ='bar');
$foo['newkey'] = 'newvalue';

--
Pierre

Jan 19 '07 #2

P: n/a
On 19 Jan 2007 10:15:09 -0800, "Pierre L." <lo************@gmail.com>
wrote:
>On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em...@address.comwrote:
>How can I append a new key-value pair to an associative array?

Just add it:
$foo = array( 'foo' ='bar');
$foo['newkey'] = 'newvalue';
Ahh, thank you.

Ken
Jan 19 '07 #3

P: n/a
Pierre L. wrote:
On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em...@address.comwrote:
>How can I append a new key-value pair to an associative array?

Just add it:
$foo = array( 'foo' ='bar');
$foo['newkey'] = 'newvalue';

--
Pierre
Also really cool when you are just adding items to an array w/out keys:

$myarray=array('item1','item2');
$myarray[] = 'item3';
$myarray[] = 'item4';

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jan 20 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.