note 60475 deleted from function.strcasecmp by nlopess
| From: | nlopess@php.net | Date: | Sun, 08 Jan 2006 11:38:11 +0000 |
| Subject: | note 60475 deleted from function.strcasecmp by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101396@lists.php.net to get a copy of this message | ||
Note Submitter: borniko at libero dot it
----
If you want to check out if a string is contained into another longer:
<?php
function contains($str, $pattern)
{
$len = strlen( $str );
$len_pat = strlen( $pattern );
for( $i = 0; $i < $len; $i ++ )
{
$check = substr( $str, $i, $len_pat );
if ( strcasecmp($check, $pattern) == 0 )
{
return true;
}
}
return false;
}
?>
$str the string you're watching in
$pattern the string you're looking for