Answers for "array pop by value php"

PHP
23

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

array pop php

<?php
//array_pop — Pop the element off the end of array
  
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_pop($stack);
print_r($stack);

Array
(
    [0] => orange
    [1] => banana
    [2] => apple
)
?>
Posted by: Guest on December-07-2021
0

php array pop by value

$arr = array_diff($arr, array('remove_me', 'remove_me_also'));
Posted by: Guest on March-31-2022

Browse Popular Code Answers by Language