src/helpers/helpers.php
/**
 * Get the index of the needle using a case insensitive search. Keeps a local
 * copy of the normalized haystack for quicker lookup on the same array
 * @staticvar array $localCopy
 * @staticvar string $checksum
 * @param string $needle
 * @param array $haystack
 * @return bool
 */
Get the index of the needle using a case insensitive search.
Get the index of the needle using a case insensitive search .
function array_searchi(string $needle, array $haystack)
{
    static $localCopy = [];
    static $checksum = null;
    $haystackChecksum = md5(json_encode($haystack));
    if($checksum != $haystackChecksum) {
        $checksum = $haystackChecksum;
        $localCopy = array_map('strtolower', $haystack);
    }    
    return array_search($needle, $localCopy); 
}
function array_searchi ( string $ needle , array $ haystack ) { static $ localCopy = [ ] ; static $ checksum = null ; $ haystackChecksum = md5 ( json_encode ( $ haystack ) ) ; if ( $ checksum != $ haystackChecksum ) { $ checksum = $ haystackChecksum ; $ localCopy = array_map ( 'strtolower' , $ haystack ) ; } return array_search ( $ needle , $ localCopy ) ; }
Get the index of the needle using a case insensitive search.
Get the index of the needle using a case insensitive search .