|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-07-14 18:37 UTC] andrei@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
When using the limit parameter on preg_split(), the last element of the resulting array is truncated at chr(0) (if there is one) instead of extending to the end of the source string as it should. The same problem is not found in explode(). The following code snippet demonstrates the problem: <?php $string="a1a-b2b-c". chr(0). "c-d4d-e5e-f6f"; list($a1a, $b2b, $rest)=explode("-", $string, 3); echo "explode: ", strlen($rest); // should be, and is, 15 echo "<br>\n"; // for html aesthetics only list($a1a, $b2b, $rest)=preg_split("/-/", $string, 3); echo "preg_split: ", strlen($rest); // should be 15, actually is 1 because it terminates at the chr(0) ?> The problem doesn't appear to affect any of the elements except the last one when limit is used.