note 50012 deleted from function.preg-match-all by colder
| From: | colder@php.net | Date: | Mon, 16 Apr 2007 16:55:50 +0000 |
| Subject: | note 50012 deleted from function.preg-match-all by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125457@lists.php.net to get a copy of this message | ||
Note Submitter: arias at elleondeoro dot com
----
If you want to find all positions and his length, you can use the next function:
<?php
function preg_match_all_positions($pattern, $subject, &$count=null, $flags=0, $offset=0) {
for ($count=0; preg_match($pattern, $subject, $match, $flags, $offset); $count++) {
$positions[0][] = $pos = strpos($subject, $match[0], $offset);
$positions[1][] = $len = strlen($match[0]);
$offset = $pos+$len;
}
return $positions;
}
?>