Home > Article > Backend Development > PHP uses array_search function to implement array search_PHP tutorial
The example in this article describes how PHP uses the array_search function to implement array search. Share it with everyone for your reference. The specific implementation method is as follows:
3 45 |
$array = array(4,5,7,8,9,10);
$found = array_search(8, $array);
//Call the array_search function and output the search results
<🎜>if($found) //If the output key is found<🎜>
<🎜>echo "Found, key is ".$found;<🎜>
<🎜>else //If not found, output error message<🎜>
<🎜>echo "not found";<🎜>
<🎜>?>
|