php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rm at drgs dot no
New email:
PHP Version: OS:

 

 [2007-09-22 20:11 UTC] rm at drgs dot no
Description:
------------
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 
"\r\n":

$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:
----------------
Array
(
    [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 />
Array
(
    [0] => 13
    [1] => 10
)


Patches

Pull Requests

History

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] nlopess@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 08:01:27 2024 UTC