What are potential pitfalls when using in_array() function in PHP?

One potential pitfall when using the in_array() function in PHP is that it performs a loose comparison by default, which can lead to unexpected results. To ensure strict comparison, you can set the third parameter of in_array() to true.

// Using in_array() with strict comparison
$my_array = [1, 2, 3];
$value = 1;

if (in_array($value, $my_array, true)) {
    echo "Value found in array with strict comparison.";
} else {
    echo "Value not found in array with strict comparison.";
}