#32965 [NEW]: preg_split PREG_SPLIT_DELIM_CAPTURE

From: Date: Fri, 06 May 2005 15:05:16 +0000
Subject: #32965 [NEW]: preg_split PREG_SPLIT_DELIM_CAPTURE
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78712@lists.php.net to get a copy of this message
From:             elegua at hotmail dot com
Operating system: Sun
PHP version:      5CVS-2005-05-06 (dev)
PHP Bug Type:     Feature/Change Request
Bug description:  preg_split PREG_SPLIT_DELIM_CAPTURE

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")

-- 
Edit bug report at http://bugs.php.net/?id=32965&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32965&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32965&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32965&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32965&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32965&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32965&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32965&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32965&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32965&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32965&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=32965&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=32965&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32965&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32965&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32965&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32965&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32965&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32965&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32965&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32965&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#78712) next »