Results 1 to 6 of 6

Thread: Appending an Array

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Appending an Array

    I have an array setup like this:

    PHP Code:
    $CONFIG = Array(
        
    thing => "thing",
        
    thing2 => "thing2",
        
    thing3 => "thing3"); 
    How can I add another item to this array later?

    Something like:

    PHP Code:
    $CONFIG[] = thing4 => "thing4"
    or something?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Try

    PHP Code:
    array_push($CONFIG"thing4"); 
    Baaaaaaaaah

  3. #3
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Both will work if you change array_push($CONFIG, "thing4"); to

    PHP Code:
    array_push($CONFIGthing4 => "thing4"); 
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    cool, thanks
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    why not

    $CONFIG[thing4] = "thing4";

    unless the thing is dynamic then it would be

    $CONFIG['$thing'] = "thing4";

  6. #6

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman

    $CONFIG['$thing'] = "thing4";
    Didn't know it would work that way. Thanks!
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width