note 74521 added to function.preg-match-all

From: Date: Sun, 15 Apr 2007 21:06:10 +0000
Subject: note 74521 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-125425@lists.php.net to get a copy of this message
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 ) ) ---- Server IP: 69.147.83.197 Probable Submitter: 76.199.199.95 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- https://master.php.net/note/edit/74521 Del: integrated -- https://master.php.net/note/delete/74521/integrated Del: useless -- https://master.php.net/note/delete/74521/useless Del: bad code -- https://master.php.net/note/delete/74521/bad+code Del: spam -- https://master.php.net/note/delete/74521/spam Del: non-english -- https://master.php.net/note/delete/74521/non-english Del: in docs -- https://master.php.net/note/delete/74521/in+docs Del: other reasons-- https://master.php.net/note/delete/74521 Reject -- https://master.php.net/note/reject/74521 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125425) next »