ID:               44621
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mpb dot mail at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         PCRE related
 Operating System: Linux
 PHP Version:      5.2.5
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The third parameter is to set the limit.

array preg_split ( string $pattern , string $subject [, int $limit [,
int $flags ]] )


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

[2008-04-02 21:53:02] mpb dot mail at gmail dot com

Description:
------------
preg_split with PREG_SPLIT_NO_EMPTY is buggy when splitting on greedy
patterns.

See reproduce code.

preg_split in PHP 4.4.8 similarly buggy.


Reproduce code:
---------------
<?php

$s = "  1   2 3  ";

print_r (preg_split ("/ +/", $s));
print_r (preg_split ("/ +/", $s, PREG_SPLIT_NO_EMPTY));

?>


Expected result:
----------------
Array
(
    [0] => 
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 
)
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
)


Actual result:
--------------
Array
(
    [0] => 
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 
)
Array
(
    [0] =>   1   2 3  
)



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


-- 
Edit this bug report at http://bugs.php.net/?id=44621&edit=1

Reply via email to