|  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
 [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.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 16 02:01:26 2019 UTC