appending to an associate array

This is a discussion on appending to an associate array within the PHP Language forums, part of the PHP Programming Forums category; Hello: How can I append a new key-value pair to an associative array? Thanks, Ken...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-19-2007
Ken Loomis
 
Posts: n/a
Default appending to an associate array

Hello:

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

Thanks,

Ken
Reply With Quote
  #2 (permalink)  
Old 01-19-2007
Pierre L.
 
Posts: n/a
Default Re: appending to an associate array

On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em...@address.com> wrote:

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


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

--
Pierre

Reply With Quote
  #3 (permalink)  
Old 01-19-2007
Ken Loomis
 
Posts: n/a
Default Re: appending to an associate array

On 19 Jan 2007 10:15:09 -0800, "Pierre L." <lombard.pierre@gmail.com>
wrote:

>On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em...@address.com> wrote:
>
>> 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
Reply With Quote
  #4 (permalink)  
Old 01-20-2007
Kenneth Downs
 
Posts: n/a
Default Re: appending to an associate array

Pierre L. wrote:

> On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em...@address.com> wrote:
>
>> 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)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:30 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0