Bug #18341: problem w/ preg_split re: limit and chr(0)

From: Date: Sun, 14 Jul 2002 20:23:34 +0000
Subject: Bug #18341: problem w/ preg_split re: limit and chr(0)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14154@lists.php.net to get a copy of this message
From: nospam@1111-internet.com Operating system: FreeBSD 4.0 PHP version: 4.2.1 PHP Bug Type: PCRE related Bug description: problem w/ preg_split re: limit and chr(0) 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. -- Edit bug report at http://bugs.php.net/?id=18341&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18341&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18341&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18341&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18341&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18341&r=support Expected behavior: http://bugs.php.net/fix.php?id=18341&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18341&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18341&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18341&r=globals

« previous php.bugs (#14154) next »