note 65313 deleted from function.strpos by nlopess
| From: | nlopess@php.net | Date: | Fri, 28 Apr 2006 16:00:20 +0000 |
| Subject: | note 65313 deleted from function.strpos by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110010@lists.php.net to get a copy of this message | ||
Note Submitter: oliver
----
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;
}
?>