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...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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) |