note 65313 added to function.strpos
| From: | oliver at osu1 dot php dot net | Date: | Fri, 28 Apr 2006 15:35:58 +0000 |
| Subject: | note 65313 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109995@lists.php.net to get a copy of this message | ||
hi,
please find enclosed an example for a function which searches a string for 'needles'
($needleArray), case-insensitiv and match-case:
<?PHP
function checkString($theString, $needleArray) {
$s = strtolower($theString);
for ($i = 0; $i < count ($needleArray); $i++) {
$thePos = strpos($s,$needleArray[$i]);
if ($thePos > -1) {
if (strlen($s) == $thePos + strlen($needleArray[$i]) || $s[$thePos +
strlen($needleArray[$i])] == " ")
return true;
}
}
return false;
}
?>
----
Server IP: 195.222.164.18
Probable Submitter: 81.13.39.150
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/note/edit/65313
Del: integrated -- http://master.php.net/note/delete/65313/integrated
Del: useless -- http://master.php.net/note/delete/65313/useless
Del: bad code -- http://master.php.net/note/delete/65313/bad+code
Del: spam -- http://master.php.net/note/delete/65313/spam
Del: non-english -- http://master.php.net/note/delete/65313/non-english
Del: in docs -- http://master.php.net/note/delete/65313/in+docs
Del: other reasons-- http://master.php.net/note/delete/65313
Reject -- http://master.php.net/note/reject/65313
Search -- http://master.php.net/manage/user-notes.php