Edit report at http://bugs.php.net/bug.php?id=16512&edit=1

 ID:                 16512
 Comment by:         admin2011 at luebker dot org
 Reported by:        bogien at conecto dot pl
 Summary:            PREG_SPLIT_DELIM_CAPTURE does not work
 Status:             Closed
 Type:               Bug
 Package:            PCRE related
 Operating System:   Win32, Linux
 PHP Version:        4.1.2
 Block user comment: N
 Private report:     N

 New Comment:

very useful information, please add to documentation or highlight the
phrase "parenthesized expression". Thanks.


Previous Comments:
------------------------------------------------------------------------
[2002-09-24 04:54:03] ed at avi dot ru

It will be a nice idea to put this example to documentation; I was
already going to send a bug report about PREG_SPLIT_DELIM_CAPTURE when I
found this article.

------------------------------------------------------------------------
[2002-04-09 09:10:23] [email protected]

Read the manual:



PREG_SPLIT_DELIM_CAPTURE



If this flag is set, parenthesized expression in the delimiter pattern
will be captured and returned as well. This flag was added for 4.0.5.



So your pattern should look like:

/(a)/



and presto, it works.

------------------------------------------------------------------------
[2002-04-09 08:59:34] bogien at conecto dot pl

PREG_SPLIT_DELIM_CAPTURE does not work - preg_split() simply omits the
delimiters disregarding the flag.



The following line:



print_r(preg_split('/a/', 'mama', -1, PREG_SPLIT_DELIM_CAPTURE));



...returns:



Array

(

    [0] => m

    [1] => m

    [2] => 

)



...just like without the last argument - while it should return:



Array

(

    [0] => m

    [1] => a

    [2] => m

    [3] => a

    [4] => 

)



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=16512&edit=1

Reply via email to