note 74521 deleted from function.preg-match-all by colder
| From: | colder@php.net | Date: | Mon, 16 Apr 2007 17:06:12 +0000 |
| Subject: | note 74521 deleted from function.preg-match-all by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125478@lists.php.net to get a copy of this message | ||
Note Submitter: phpnet at yoxel dot com
----
I believe the description of the matches array returned by this function is a little wrong:
> In this case, $matches[0] is the first set of matches, and
>$matches[0][0] has text matched by full pattern, $matches[0
>[1] has text matched by first subpattern and so on. Similarly
>$matches[1] is the second set of matches, etc.
What I see is that $matches[0] is an array of all full pattern matches, that is $matches[0][0],
$matches[0][1], ..., $matches[0][N] are all full pattern matches.
And $matches[1] through $matches[N] are the arrays with subpattern matches ...
Has anyone noticed this besides me?
See what I get:
$txt="<rid>33805,566</rid>\n<rid>33806</rid>";
preg_match_all('/<rid>(.*?)<\/rid>/is',$txt,$matches);
print_r($matches);
Array
(
[0] => Array
(
[0] => <rid>33805,566</rid>
[1] => <rid>33806</rid>
)
[1] => Array
(
[0] => 33805,566
[1] => 33806
)
)