Skip to content

Instantly share code, notes, and snippets.

@dextermb
Forked from sepehr/in_arrayi.php
Created October 11, 2016 11:21
Show Gist options
  • Save dextermb/0821c10a81179ff08b20f87ea1b11c2e to your computer and use it in GitHub Desktop.
Save dextermb/0821c10a81179ff08b20f87ea1b11c2e 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.
*
* @return bool
*/
function in_arrayi($needle, $haystack)
{
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment