PHP 4.0 Bug #9265: passing preg_split a limit parameter of 0 supresses all matches
| From: | chuck at horde dot org | Date: | Wed, 14 Feb 2001 21:33:50 +0000 |
| Subject: | PHP 4.0 Bug #9265: passing preg_split a limit parameter of 0 supresses all matches | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46602@lists.php.net to get a copy of this message | ||
From: chuck@horde.org
Operating system: Linux 2.2
PHP version: 4.0 Latest CVS (14/02/2001)
PHP Bug Type: PCRE related
Bug description: passing preg_split a limit parameter of 0 supresses all matches
Somewhere in the last few weeks, preg_split changed so that specifiying a limit parameter of 0
returns the string to be split unchanged. Before that, 0 was seemingly treated as no limit, meaning
that you could safely specify 0 as the limit argument in order to specify a flag as the fourth
argument.
<?php
$foo = 'a|b|c|d';
$m = preg_split('/|/', $foo, 0);
var_dump($m);
?>
will return everything in the same array, whereas if the limit argument is left off (or increased),
the string gets split up. The behavior allowing 0 to be no limit should be returned, or another safe
argument for limit that means no limit documented.
--
Edit Bug report at: http://bugs.php.net/?id=9265&edit=1