how to use array_splice

Discussion in 'PHP' started by whjtoby, Nov 23, 2010.

  1. #1
    In php the array_splice (); how to use
     
    whjtoby, Nov 23, 2010 IP
  2. mikecampbell

    mikecampbell Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Straight from the manual http://ca2.php.net/manual/en/function.array-splice.php

    $input = array("red", "green", "blue", "yellow");
    array_splice($input, 2);
    // $input is now array("red", "green")
    
    $input = array("red", "green", "blue", "yellow");
    array_splice($input, 1, -1);
    // $input is now array("red", "yellow")
    
    $input = array("red", "green", "blue", "yellow");
    array_splice($input, 1, count($input), "orange");
    // $input is now array("red", "orange")
    
    $input = array("red", "green", "blue", "yellow");
    array_splice($input, -1, 1, array("black", "maroon"));
    // $input is now array("red", "green",
    //          "blue", "black", "maroon")
    
    $input = array("red", "green", "blue", "yellow");
    array_splice($input, 3, 0, "purple");
    // $input is now array("red", "green",
    //          "blue", "purple", "yellow");
    PHP:
     
    mikecampbell, Nov 23, 2010 IP
  3. look4guna

    look4guna Active Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    go to www.php.net and look for array functions. you'll end up with enough information you needed;)
     
    look4guna, Nov 24, 2010 IP
  4. whjtoby

    whjtoby Greenhorn

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #4
    thanks , I'm looking at php.net
     
    whjtoby, Nov 24, 2010 IP