note 45088 added to function.strpos
| From: | philip at osu1 dot php dot net | Date: | Wed, 25 Aug 2004 22:52:25 +0000 |
| Subject: | note 45088 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75264@lists.php.net to get a copy of this message | ||
Many people look for in_string which does not exist in PHP, so, here's the most efficient form
of in_string() (that works in both PHP 4/5) that I can think of:
<?php
function in_string($needle, $haystack, $insensitive = 0) {
if ($insensitive) {
return (false !== stristr($haystack, $needle)) ? true : false;
} else {
return (false !== strpos($needle, $haystack)) ? true : false;
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45088
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45088&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45088&report=yes
Search -- http://master.php.net/manage/user-notes.php