Case inSensitive in_array() With PHP

You might already know that PHP’s in_array() function matches the string needle case sensitive way. But for matches the string needle case insensitive way in PHP there is nothing. It is quite simple. Here it is:

function in_arrayi($needle, $haystack)
    foreach ($haystack as $value) {
       if (strtolower($value) == strtolower($needle))
       return true;
    return false;

Please note that this case-insensitive version is, at least, 5 times slower than in_array().