What are the potential pitfalls of using in_array with strict comparison in PHP?

When using in_array with strict comparison in PHP, the potential pitfall is that it may not work as expected when searching for values that are integers but stored as strings in the array. This is because strict comparison also checks the data type, so a strict comparison between an integer and a string will return false. To solve this issue, you can use array_search instead of in_array with strict comparison. array_search will return the key of the value if found, or false if not found, without considering the data type.

$array = ['1', '2', '3'];

if(array_search(2, $array) !== false) {
    echo "Value found in array";
} else {
    echo "Value not found in array";
}