|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-05-17 06:06 UTC] danielklein at airpost dot net
[2016-08-20 10:28 UTC] cmb@php.net
-Package: *Regular Expressions
+Package: PCRE related
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Description: ------------ When using preg_match_all with named capture groups, the result array will contain one entry with a numeric key in addition to one entry with the name of the group. Assuming I put the named capture group there on purpose, there is no reason why I would need the numeric index. It only bloats the result array. As a user I would like to have an option that returns the results without the superfluous numeric index. Test script: --------------- <?php preg_match_all( '/This message contains (?<items>[\d]+) items/', 'This message contains 42 items', $matches ); print_r($matches); Expected result: ---------------- Array ( [0] => Array ( [0] => This message contains 42 items ) [items] => Array ( [0] => 42 ) ) Actual result: -------------- Array ( [0] => Array ( [0] => This message contains 42 items ) [items] => Array ( [0] => 42 ) [1] => Array ( [0] => 42 ) )