Array question?

Discussion in 'PHP' started by Derpost, Jun 19, 2011.

  1. #1
    i want to unset value as 12 in this array "" [0] = 15 , [1] => 12 , [2] => 20 "".
    i can remove [1] but value as 12 require for remove [1].

    i want to remove value as 12 :)

    but How?
     
    Derpost, Jun 19, 2011 IP
  2. The Webby

    The Webby Peon

    Messages:
    1,852
    Likes Received:
    30
    Best Answers:
    1
    Trophy Points:
    0
    #2
    This should do:
    
    $sampleArray = array(0 => 15, 1 => 12, 2 => 20);
    $key = array_search(12, $sampleArray);
    unset($sampleArray[$key]);
    
    PHP:
     
    The Webby, Jun 19, 2011 IP
  3. Derpost

    Derpost Active Member

    Messages:
    95
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #3
    very thanks :)
     
    Derpost, Jun 19, 2011 IP