If any key before the searched one is numeric zero, then that key is returned, because it is performing a "loose" match dominated by the array's data type, and "sharp" (if converted to int
) counts as zero. Using a strict checking, the correct value is found.
Otherwise, by executing
$testcopy = array_map('strval', $testcopy);
so that values are translated to strings, it works also with "loose" check.