#47727 [Opn->Bgs]: Error in Documentation: explode()
ID: 47727
Updated by: rquadling@php.net
Reported By: me at lukearmstrong dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: n/a
PHP Version: Irrelevant
New Comment:
Duplicate http://bugs.php.net/bug.php?id=47560,
http://bugs.php.net/bug.php?id=47546
Previous Comments:
------------------------------------------------------------------------
[2009-03-20 09:27:30] me at lukearmstrong dot co dot uk
Description:
------------
Error in Documentation
http://uk.php.net/explode
array explode(string $delimiter, string $string [, int $limit = -1])
The default value for $limit is not -1. I assumed it would be 0, but
that does not output what I expected either. The default appears to be a
value that cannot be set, ideally this should be made clear in the
documentation.
Another bug is listed saying the default value for $limit is 0, if the
documentation has been updated to show this, the documentation will
still be wrong.
Reproduce code:
---------------
$string = 'path/to/folder/';
$array = explode('/', $string);
print_r($array)
Output: Array ( [0] => path [1] => to [2] => folder [3] => )
$string = 'path/to/folder/';
$array = explode('/', $string, -1);
print_r($array)
Output: Array ( [0] => path [1] => to [2] => folder )
$string = 'path/to/folder/';
$array = explode('/', $string, 0);
print_r($array)
Output: Array ( [0] => path/to/folder/ )
Expected result:
----------------
http://uk.php.net/explode
array explode(string $delimiter, string $string [, int $limit])
Actual result:
--------------
http://uk.php.net/explode
array explode(string $delimiter, string $string [, int $limit = -1])
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47727&edit=1
Thread (4 messages)