note 80578 added to function.array-search

From: Date: Wed, 23 Jan 2008 12:48:54 +0000
Subject: note 80578 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-135330@lists.php.net to get a copy of this message
In response to <phpawe at aweawe dot cjb dot net>'s comments: Your function still uses strtolower() inside a loop, a better example of a case-insensitive array search is the following: <?php function array_isearch($str, $array) { foreach($array as $k => $v) { if(strcasecmp($str, $v) == 0) return $k; } return false; } ?> ---- Server IP: 194.145.210.3 Probable Submitter: 193.164.107.130 ---- Manual Page -- http://www.php.net/manual/en/function.array-search.php Edit -- https://master.php.net/note/edit/80578 Del: integrated -- https://master.php.net/note/delete/80578/integrated Del: useless -- https://master.php.net/note/delete/80578/useless Del: bad code -- https://master.php.net/note/delete/80578/bad+code Del: spam -- https://master.php.net/note/delete/80578/spam Del: non-english -- https://master.php.net/note/delete/80578/non-english Del: in docs -- https://master.php.net/note/delete/80578/in+docs Del: other reasons-- https://master.php.net/note/delete/80578 Reject -- https://master.php.net/note/reject/80578 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135330) next »