Are there any potential performance pitfalls to be aware of when using in_array() in PHP, especially with large arrays?

When using in_array() in PHP with large arrays, performance can become an issue if the function needs to search through a large number of elements. This can slow down the script significantly, especially if the array is not sorted. To mitigate this, consider using associative arrays or other data structures for faster lookups, or sorting the array before using in_array() for improved performance.

// Example of using associative arrays for faster lookups
$myArray = ['apple' => true, 'banana' => true, 'orange' => true];

if(isset($myArray['banana'])) {
    echo 'Found banana!';
}