#49395 [Opn->Csd]: typo in the code
| From: | rquadling@php.net | Date: | Fri, 28 Aug 2009 10:57:11 +0000 |
| Subject: | #49395 [Opn->Csd]: typo in the code | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2681@lists.php.net to get a copy of this message | ||
ID: 49395
Updated by: rquadling@php.net
Reported By: a1call at hotmail dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-08-28 10:56:51] svn@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=287845
Log: Example missing some output.
Fix for bug#49395
------------------------------------------------------------------------
[2009-08-27 22:44:24] a1call at hotmail dot com
Description:
------------
The example code on page:
http://ca3.php.net/preg_match_all
is skipping a variable and does not produce te reported result.
Should be:
<?php
// The \\2 is an example of backreferencing. This tells pcre that
// it must match the second set of parentheses in the regular
expression
// itself, which would be the ([\w]+) in this case. The extra backslash
is
// required because the string is in double quotes.
$html = "<b>bold text</b><a href=howdy.html>click me</a>";
preg_match_all("/(<([\w]+)[^>]*>)(.*?)(<\/\\2>)/", $html, $matches,
PREG_SET_ORDER);
foreach ($matches as $val) {
echo "matched: " . $val[0] . "\n";
echo "part 1: " . $val[1] . "\n";
echo "part 2: " . $val[2] . "\n";
echo "part 3: " . $val[3] . "\n\n";
}
?>
instead of:
<?php
// The \\2 is an example of backreferencing. This tells pcre that
// it must match the second set of parentheses in the regular
expression
// itself, which would be the ([\w]+) in this case. The extra backslash
is
// required because the string is in double quotes.
$html = "<b>bold text</b><a href=howdy.html>click me</a>";
preg_match_all("/(<([\w]+)[^>]*>)(.*?)(<\/\\2>)/", $html, $matches,
PREG_SET_ORDER);
foreach ($matches as $val) {
echo "matched: " . $val[0] . "\n";
echo "part 1: " . $val[1] . "\n";
echo "part 2: " . $val[3] . "\n";
echo "part 3: " . $val[4] . "\n\n";
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49395&edit=1