|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-28 13:37 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: PCRE related
-Assigned To:
+Assigned To: cmb
[2016-08-28 13:37 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
Description: ------------ This is to do with Preg Split. When preg_split is used with the flag PREG_SPLIT_OFFSET_CAPTURE, it returns an array, with the matched string, followed by the offset. When the flag PREG_SPLIT_DELIM_CAPTURE is used, it first returns the matched string, and then returns the string. I am not sure if the functionality of PREG_SPLIT_DELIM_CAPTURE should return as an array, it would be far more useful it did work this way. Is this a bug with my version? Or, is this indeed the way it should function? Reproduce code: --------------- $result=""; $operations=preg_split("/(&\d*=op)/",$ops); foreach($operations as $op) { $allOps[]=$op; } Expected result: ---------------- each allOps will have an array of string and delim for each match found. Actual result: -------------- array(allOps[0]=>"some string",allOps[1]="delim")