note 90184 deleted from function.strpos by thiago
| From: | thiago@php.net | Date: | Thu, 09 Apr 2009 12:12:42 +0000 |
| Subject: | note 90184 deleted from function.strpos by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153006@lists.php.net to get a copy of this message | ||
Note Submitter: cerverg
----
Hi guys I found a simple solution for wildcard strpos
here is the function :
function strposw($search,$subject) {
$pattern = '/^'.$search.'/';
$len=strlen($subject);
for( $i=0;$i<=$len;$i++) {
preg_match($pattern, substr($subject,$i), $matches, PREG_OFFSET_CAPTURE);
if ($matches[0]) return $i;
}
return 0;
}
echo strposw('def','abcdef');
it shows that the position is 3 ;