ID:          37913
 Updated by:  [EMAIL PROTECTED]
 Reported By: tom at foreignproperty dot com
-Status:      Open
+Status:      Bogus
 Bug Type:    Documentation problem
 PHP Version: Irrelevant
 New Comment:

No. The example is correct. It shows how to use nested parenteses and
backreferences.


Previous Comments:
------------------------------------------------------------------------

[2006-06-26 09:30:28] tom at foreignproperty dot com

look at the array keys.
it goes $matches[0], $matches[1], then jumps to $matches[3] and
$matches[4]

Shouldn't part 2 be matches[2], and part 3 be $matches[3]?

------------------------------------------------------------------------

[2006-06-26 08:40:08] [EMAIL PROTECTED]

No, that's perfectly correct.

The regx is "/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/".

So,
[1] correspond to (<([\w]+)[^>]*>),
[2] correspond to ([\w]+),
[3] correspond to (.*), and
[4] correspond to (<\/\\2>).


------------------------------------------------------------------------

[2006-06-26 08:16:06] tom at foreignproperty dot com

Description:
------------
In the description for preg_match_all, in the 2nd example, Find
matching HTML tags (greedy), the part 2 and part 3 array values are
wrong ($matches[3], $matches[4]).

  echo "matched: " . $matches[0][$i] . "\n";
  echo "part 1: " . $matches[1][$i] . "\n";
>>  echo "part 2: " . $matches[3][$i] . "\n";       <<
>>  echo "part 3: " . $matches[4][$i] . "\n\n";     <<






------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37913&edit=1

Reply via email to