Secondo la documentazione ufficiale al http://php.net/manual/en/function.array-search.php:
Attenzione Questa funzione può restituire il Booleano FALSE, ma può anche restituire un valore non booleano valutato come FALSE. Si prega di leggere la sezione su booleani per ulteriori informazioni. Utilizzare l'operatore === per testare il valore di ritorno di questa funzione.
Vedi questo esempio:
$foundKey = array_search(12345, $myArray);
if(!isset($foundKey)){
// If $myArray is null, then $foundKey will be null too.
// Do something when both $myArray and $foundKey are null.
} elseif ($foundKey===false) {
// $myArray is not null, but 12345 was not found in the $myArray array.
}else{
// 12345 was found in the $myArray array.
}
fonte
2018-02-27 15:24:33
E 'più veloce di provare e vedere il risultato che chiedere esso. –
il risultato del controllo is_int() visto che restituisce una chiave .. – PolarTheDog