What are the potential pitfalls of using in_array function in PHP?

One potential pitfall of using the in_array function in PHP is that it performs a loose comparison by default, which can lead to unexpected results. To avoid this issue, you can use the strict parameter of in_array to perform a strict comparison, ensuring both the value and the type match.

// Using strict parameter to perform a strict comparison
$value = 5;
$array = [1, 2, 3, 4, 5];
if (in_array($value, $array, true)) {
    echo "Value found in array";
} else {
    echo "Value not found in array";
}