#47727 [Bgs->Opn]: Error in Documentation: explode()

From: Date: Wed, 01 Apr 2009 17:30:12 +0000
Subject: #47727 [Bgs->Opn]: Error in Documentation: explode()
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2076@lists.php.net to get a copy of this message
 ID:               47727
 Updated by:       mattwil@php.net
 Reported By:      me at lukearmstrong dot co dot uk
-Status:           Bogus
+Status:           Open
 Bug Type:         Documentation problem
 Operating System: n/a
 PHP Version:      Irrelevant
 New Comment:

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.


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

[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)

« previous php.doc.bugs (#2076) next »