Beware when using array_search to a mix of string and integer where prefixes of keys may collide, as in my case I have encountered the following situation:
Assume you have the following array:
<?php
$arr = [
1 => 'index 0',
2 => 'index 1',
3 => 'index 2',
'3anothersuffix' => 'index 3'
];
$index1 = array_search('3', array_keys($arr)); $index2 = array_search('3anothersuffix', array_keys($arr)); ?>
$index1 and $index2 will be the same
after using strict type search:
<?php
$index1 = array_search('3', array_keys($arr), true); $index2 = array_search('3anothersuffix', array_keys($arr), true); ?>
it will not find $index1 at all while returning a correct value for $index2;