|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42737 Notice: preg_split(): Unknown error
Submitted: 2007-09-22 20:11 UTC Modified: 2007-10-07 13:57 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rm at drgs dot no Assigned: nlopess (profile)
Status: Closed Package: PCRE related
PHP Version: 5.2.4 OS: Mac OS X 10.3.9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rm at drgs dot no
New email:
PHP Version: OS:


 [2007-09-22 20:11 UTC] rm at drgs dot no
I'm splitting a string into characters with this:

preg_split('//u', $string, - 1, PREG_SPLIT_NO_EMPTY);

I get a notice on an uknown error which happens when I use the 
unicode suffix u in the pattern and when the input string is 

$string = chr(13).chr(10);

but not when i drop the unicode option, ie. this works fine:
preg_split('//', $string, - 1, PREG_SPLIT_NO_EMPTY);

Reproduce code:
$string = chr(13).chr(10);

$array = preg_split('//u', $string, - 1, PREG_SPLIT_NO_EMPTY));

print_r(array_map('ord', $array));

Expected result:
    [0] => 13
    [1] => 10

Actual result:
<br />
<b>Notice</b>:  preg_split() [<a href='function.preg-
split'>function.preg-split</a>]: Unknown error in <b>/Users/
myname/Sites/script.php</b> on line <b>73</b><br />
    [0] => 13
    [1] => 10


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-22 20:17 UTC] rm at drgs dot no
this seems to be the case with all strings which end with "\r\n"

btw, theres an extra obsolete parantesis at the end of the second 
line in reproduce code, sorry
 [2007-10-07 13:57 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Oct 01 11:01:24 2023 UTC