Answers for "php delete array item by value"

PHP
15

php delete array item by value

$colors = array("blue","green","red");

//delete element in array by value "green"
if (($key = array_search("green", $colors)) !== false) {
    unset($colors[$key]);
}
Posted by: Guest on October-30-2019
0

php remove element from array by value

// matrix array
foreach($appsList as $key => $app) {
            if($app["app_status"] !== "approved") {
                // remove orange apps
                unset($appsList[$key]);
            }
}
Posted by: Guest on January-15-2021
0

how to delete item from array php

$array = [0 => "a", 1 => "b", 2 => "c"];
unset($array[1]);
Posted by: Guest on October-20-2020
0

php delete array item by value

$colors = arrray("blue","green","red");
if(($key = array_search("greeb",$colors)) !== false)
{
unset("$colors[$key]);
}
Posted by: Guest on June-21-2021

Code answers related to "php delete array item by value"

Browse Popular Code Answers by Language