php.net |  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 41 = ?
Subscribe to this entry?

 
 [2016-12-10 14:02 UTC] chris at ocproducts dot com
Description:
------------
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-10 16:17 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Documentation problem +Package: PCRE related -Assigned To: +Assigned To: cmb
 [2016-12-10 16:29 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=341360
Log: Fix #73709: preg_match_all PREG_OFFSET_CAPTURE documentation incorrect
 [2016-12-10 16:29 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-12-10 16:29 UTC] cmb@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.
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=f6b3cb343776c44d10ad79dc56278caef5ba5372
Log: Fix #73709: preg_match_all PREG_OFFSET_CAPTURE documentation incorrect
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC