appending to an associate array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken Loomis

    appending to an associate array

    Hello:

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

    Thanks,

    Ken
  • Pierre L.

    #2
    Re: appending to an associate array

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

    --
    Pierre

    Comment

    • Ken Loomis

      #3
      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.comw rote:
      >
      >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

      Comment

      • Kenneth Downs

        #4
        Re: appending to an associate array

        Pierre L. wrote:
        On Jan 19, 7:04 pm, Ken Loomis <not_a_real_em. ..@address.comw rote:
        >
        >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 )

        Comment

        Working...