Skip to content

Instantly share code, notes, and snippets.

@babeuloula
Forked from sepehr/in_arrayi.php
Last active April 5, 2018 21:24
Show Gist options
  • Save babeuloula/adb16b2f00b9c3975919 to your computer and use it in GitHub Desktop.
Save babeuloula/adb16b2f00b9c3975919 to your computer and use it in GitHub Desktop.
PHP: Case-insensitive in_array()
<?php
/**
* Case-insensitive in_array() wrapper.
*
* @param mixed $needle Value to seek.
* @param array $haystack Array to seek in.
* @param bool $strict If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack.
*
* @return bool
*/
function in_arrayi($needle, $haystack, $strict)
{
return in_array(strtolower($needle), array_map('strtolower', $haystack), $strict);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment