#47727 [Opn->Csd]: Error in Documentation: explode()
ID: 47727
Updated by: rquadling@php.net
Reported By: me at lukearmstrong dot co dot uk
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: n/a
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-04-01 17:30:10] mattwil@php.net
Reopening this one since it's actually about the documentation problem.
(See the other bugs referenced above.)
That -1 shouldn't be there since it's misleading. The default is just
"unlimited," or the length of the input string, or PHP_INT_MAX, etc.
------------------------------------------------------------------------
[2009-03-20 13:58:05] rquadling@php.net
Duplicate http://bugs.php.net/bug.php?id=47560,
http://bugs.php.net/bug.php?id=47546
------------------------------------------------------------------------
[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)