Answers for "php find array key and remove"

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 array remove keys keep values

<?php
$array = array("size" => "XL", "color" => "gold");
print_r(array_values($array));
?>
Array
(
    [0] => XL
    [1] => gold
)
Posted by: Guest on May-13-2020
0

unset by key name php

unset($array['key-here']);
Posted by: Guest on April-28-2020

Code answers related to "php find array key and remove"

Browse Popular Code Answers by Language