note 101132 added to function.in-array
| From: | Sabrina at osu1 dot php dot net | Date: | Sun, 28 Nov 2010 21:29:45 +0000 |
| Subject: | note 101132 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174420@lists.php.net to get a copy of this message | ||
Here's another way to get around the case-sensitive issue with in_array:
<?php
function in_arrayi($needle, $haystack)
{
for($h = 0 ; $h < count($haystack) ; $h++)
{
$haystack[$h] = strtolower($haystack[$h]);
}
return in_array(strtolower($needle),$haystack);
}
?>
This is good for parsing URI's or preventing SQL injection.
----
Server IP: 192.41.42.26
Probable Submitter: 98.154.160.207
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/101132
Del: integrated -- https://master.php.net/note/delete/101132/integrated
Del: useless -- https://master.php.net/note/delete/101132/useless
Del: bad code -- https://master.php.net/note/delete/101132/bad+code
Del: spam -- https://master.php.net/note/delete/101132/spam
Del: non-english -- https://master.php.net/note/delete/101132/non-english
Del: in docs -- https://master.php.net/note/delete/101132/in+docs
Del: other reasons-- https://master.php.net/note/delete/101132
Reject -- https://master.php.net/note/reject/101132
Search -- https://master.php.net/manage/user-notes.php