[PHP-DEV] PHP 4.0 Bug #9265 Updated: passing preg_split a limit parameter of 0 supresses all matches From: andrei <email protected>
Date: 02/19/01

ID: 9265
Updated by: andrei
Reported By: chuck <email protected>
Old-Status: Open
Status: Closed
Bug Type: PCRE related
Assigned To:
Comments:

As far as I remember, 0 has never meant "no limit" - the value for that is -1. But the documentation does need to be updated.

Previous Comments:
---------------------------------------------------------------------------

[2001-02-14 16:33:50] chuck <email protected>
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.

---------------------------------------------------------------------------

ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9265&edit=2

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>