Skip to content

Instantly share code, notes, and snippets.

@sepehr
Created August 27, 2013 09:12
Show Gist options
  • Save sepehr/6351397 to your computer and use it in GitHub Desktop.
Save sepehr/6351397 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));
}
@ZamBoyle
Copy link

ZamBoyle commented Apr 19, 2021

Very clever use of the callback parameter. :)

@hembachrterran
Copy link

@Florian418
Copy link

Thx ♥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment