|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73709 preg_match_all PREG_OFFSET_CAPTURE documentation incorrect
Submitted: 2016-12-10 14:02 UTC Modified: 2016-12-10 16:29 UTC
From: chris at ocproducts dot com Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chris at ocproducts dot com
New email:
PHP Version: OS:


 [2016-12-10 14:02 UTC] chris at ocproducts dot com
The documentation against PREG_OFFSET_CAPTURE for the preg_match_all function is an exact copy & paste from the preg_match function. However, preg_match_all has 3 levels of array, while preg_match has 2 levels.

This is what the documentation says in both cases:
"If this flag is passed, for every occurring match the appendant string offset will also be returned. Note that this changes the value of matches into an array where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1."

Observe how it explicitly details the (and only the) 2 levels of returned array, while actually it has 3 levels.

I actually got very confused about PREG_OFFSET_CAPTURE and preg_match_all behaviour over the years and now I see why.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-10 16:17 UTC]
-Status: Open +Status: Verified -Package: Documentation problem +Package: PCRE related -Assigned To: +Assigned To: cmb
 [2016-12-10 16:29 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #73709: preg_match_all PREG_OFFSET_CAPTURE documentation incorrect
 [2016-12-10 16:29 UTC]
-Status: Verified +Status: Closed
 [2016-12-10 16:29 UTC]
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.
 [2020-02-07 06:06 UTC]
Automatic comment on behalf of cmb
Log: Fix #73709: preg_match_all PREG_OFFSET_CAPTURE documentation incorrect
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Sep 23 06:03:35 2021 UTC