Answers for "php remove element in array with condition"

PHP
0

php array remove value if exists

<?php
$myArray = array ('Alan', 'Peter', 'Linus', 'Larry');
$pos = array_search('Linus', $myArray);
echo 'Linus found at: '.$pos;
// Remove from array
unset($myArray[$pos]);
print_r($myArray);
?>
Posted by: Guest on April-07-2021
0

php conditionally remove element from array

foreach ($array as $key => $element) {
    if ($element['age'] > 90) {
        unset($array[$key]);
    }
}
Posted by: Guest on February-16-2021

Code answers related to "php remove element in array with condition"

Browse Popular Code Answers by Language