Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
?>
Source by onecompiler.com #
 
PREVIOUS NEXT
Tagged: #php #array #remove #exists
ADD COMMENT
Topic
Name
6+6 =