Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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]);
}
Comment

php array remove keys keep values


<?php
$array = array("size" => "XL", "color" => "gold");
print_r(array_values($array));
?>
Array
(
    [0] => XL
    [1] => gold
)
Comment

PREVIOUS NEXT
Code Example
Php :: str_replace smarty template 
Php :: laravel make model all with resources api 
Php :: calculate total time from start and end datetime in php 
Php :: if condition in smarty 
Php :: failed to open stream permission denied in php 
Php :: php sum of digits 
Php :: php echo variable 
Php :: preg_replace 
Php :: laravel routing techniques 
Php :: laravel new line in language file 
Php :: php nginx file not found 
Php :: use resource in laravel 8 
Php :: symfony get container static 
Php :: encrypt & decrypt laravel 
Php :: laravel routes return view in web.php 
Php :: woocommerce change add to cart message 
Php :: doctrine orm get all 
Php :: <?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Main loader script * * @package PhpMyAdmin */ declare(strict_types=1); 
Php :: laravel get mysql column datatype 
Php :: php check if query succeeded 
Php :: call function in php 
Php :: input file accept jpg jpeg png php 
Php :: laravel pagination with query string, laravel pagination with string 
Php :: laravel pagination vuetify 
Php :: template literals php 
Php :: diffinhours with minutes carbon 
Php :: php remove first word from string 
Php :: php foreac 
Php :: Proc file for laravel 
Php :: laravel foreign 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =