php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42159 Documentation corrup in preg_match_all
Submitted: 2007-07-31 13:47 UTC Modified: 2007-08-16 10:03 UTC
From: johannes dot ponader at web dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2007-07-31 13:47 UTC] johannes dot ponader at web dot de
Description:
------------
Hi,

the documentation of preg_match_all seems to be corrupt.

In the *Parameters* section the description for *matches* says:

"matches

    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. "

This applies only when the flag PREG_SET_ORDER is set (non-default).

The beginning "In this case" without giving information about which case is meant indicates that there is something missing. The correct documentation could be like written here in the field "Expected result".

Thanks,

Johannes Ponader


Expected result:
----------------
matches

By default, $matches[0] is an array of full pattern matches, $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on. $matches[0][0] is the first match of the full pattern, $matches[0][1] is the second match etc.. $matches[1][0] is the first match of the first subpattern.

If the Flag PREG_SET_ORDER is set, the array is ordered differently. In this case... 

(continues like in actual version)



Actual result:
--------------
matches

    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. 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-16 10:03 UTC] vrana@php.net
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.

"matches: Array of all matches in multi-dimensional array ordered according to flags."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Aug 14 04:00:03 2025 UTC