Tag Archives: array_search

array_search case insensitive

PHP’s array_search claims that it suppors a case insensitive search, well, sort of, with this message: If needle is a string, the comparison is done in a case-sensitive manner. user says: for case insensitive array_search you could use: function array_search_i($str,$array){ foreach($array as $key => $value) { if(stristr($str,$value)) return $key; } return false; } stefano says: for searching case insensitive better this: array_search(strtolower($element),array_map(‘strtolower’,$array));

Posted in Tech Tips, Web Development | Tagged , , | Leave a comment