Answers for "remove array element by value php"

PHP
17

php delete array item by value not key

$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 specific element from array

if (($key = array_search('strawberry', $array)) !== false) {
    unset($array[$key]);
}
Posted by: Guest on July-08-2020

Code answers related to "remove array element by value php"

Browse Popular Code Answers by Language