Documentation for preg_match and preg_match_all flag PREG_OFFSET_CAPTURE wrong
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
The documentation claims:
If this flag is passed, for every occurring match the appendant string offset (in bytes) will also be returned. Note that this changes the value of matches into an array of arrays where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1.
What really happens though is that "matches" becomes an array where the first element ( matches[0] ) is an array as described here. If capture groups are present, the second element ( matches[1] ) is a similar array, but with the captured groups and their offset instead of the entire match and its offset.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the PHP documentation for the preg_match and preg_match_all sections describing PREG_OFFSET_CAPTURE. Compare the wording with the reported matches[0] and capture-group behavior, then update the explanation so it accurately describes the returned array structure. Done means the documentation distinguishes the full match from captured groups and their offsets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100