Answers for "value search and remove in array in php\"

PHP
1

searching and removing element from an array php

<?php
$hackers = array ('Alan Kay', 'Peter Norvig', 'Linus Trovalds', 'Larry Page');

print_r($hackers);

// Search
$pos = array_search('Linus Trovalds', $hackers);

echo 'Linus Trovalds found at: ' . $pos;

// Remove from array
unset($hackers[$pos]);

print_r($hackers);
Posted by: Guest on May-14-2020
0

php remove element from array by value

// matrix array
foreach($appsList as $key => $app) {
            if($app["app_status"] !== "approved") {
                // remove orange apps
                unset($appsList[$key]);
            }
}
Posted by: Guest on January-15-2021

Code answers related to "value search and remove in array in php\"

Browse Popular Code Answers by Language