SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HELP MAKE unset(array[0]) AND array[1] turns to array[0]

    whenever i unset array[0] i am left with something like

    array[1], array[2], etc.

    i want array[1] to become array[0] and array[2] to become array[1]

    is there a way to unset an array key and make the rest downshift so that all the keys are still numbered correctly?

    that way my array is never missing a number like array([0],[1],[3])


    Thanks.
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $a = Array('foo','bar,'cux');
    unset($a[0])
    $a = array_merge($a);

  3. #3
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    array_shift$array ); 
    Look at the manual

  4. #4
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    Code:
    $a = Array('foo','bar,'cux');
    unset($a[0])
    $a = array_merge($a);
    thanks!
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  5. #5
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston View Post

    Look at the manual
    if I looked at the manual how would I find the function i am looking for if I don't know what its called?

    seriuosly whenever i go to php.net to find how to do something i see tons of functions and I am like "am i supposed to check every single one and see if it does what I need?" I just feel like php.net can help me figure out a function i am already using but not figure out how to do something i am clueless about.

    Thanks.
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.


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
  •