PHP Removing elements from an array

This question already has an answer here:

  • PHP: Delete an element from an array 34 answers

  • you can try this:

    $ab = milk;
    $ba = apple;
    $ca = bread;
    
    $arr=array($ab, $ba, $ca);
    if (in_array($ba, $arr))
    {
    unset($ba);
    }
    

    hope this may help you..


    Yes it has a function. that it unset().

    you can use it this way.

    $ab = milk;
    $ba = apple;
    $ca = bread;
    
    $array = array($ab, $ba, $ca);
    

    Then if you want to delete that $ba from the above array. you just call the above method as follows.

    unset($array[1]);
    

    unset the element you need to remove.

    Anyway...

    https://www.google.it/search?q=stackoverflow+remove+element+from+array+php&oq=stackoverflow+remove+element+from+array+php&aqs=chrome..69i57j0j69i64.5843j0&sourceid=chrome&ie=UTF-8

    链接地址: http://www.djcxy.com/p/30104.html

    上一篇: 如何从php数组中删除元素

    下一篇: PHP从数组中删除元素