php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47727 Error in Documentation: explode()
Submitted: 2009-03-20 09:27 UTC Modified: 2009-04-02 09:25 UTC
From: me at lukearmstrong dot co dot uk Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID:
 [2009-03-20 09:27 UTC] 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])

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-01 17:30 UTC] 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-04-02 09:25 UTC] rquadling@php.net
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.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 15:02:26 2014 UTC