FYI, remember that strict mode is something that might save you hours.
If you're searching for a string and you have a "true" boolean on the way - you will get it as result (first occurrence). Example below:
<?php
$arr = [
'foo' => 'bar',
'abc' => 'def',
'bool' => true,
'target' => 'xyz'
];
var_dump( array_search( 'xyz', $arr ) ); //bool
var_dump( array_search( 'xyz', $arr, true ) ); //target
?>