SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Array Question

  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Array Question

    Is there a way to add values to an exisiting array.

    if I have

    $array = array(1, 2, 3)
    $var = 4

    can I add $var to the end of the array and re-declare $array.

    ive searched the manual but found nothing.

    thanks

  2. #2
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    looks like array_push() will do the trick.

  3. #3
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by brdnwi
    looks like array_push() will do the trick.
    It will.

  4. #4
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or:
    Code:
    $array[] = $var;


Bookmarks

Posting Permissions

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