chrisdempsey
6/24/2017 - 11:05 PM

PHP: Case-insensitive in_array()

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));
}