Skip to content

Instantly share code, notes, and snippets.

@idleberg
Forked from sepehr/in_arrayi.php
Created January 23, 2018 11:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save idleberg/220c9cf66a8f677e7c5bd2de4b7e2253 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