|  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: None
 [2009-03-20 09:27 UTC] me at lukearmstrong dot co dot uk
Error in Documentation
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);
Output: Array ( [0] => path [1] => to [2] => folder [3] => )

$string = 'path/to/folder/';
$array = explode('/', $string, -1);
Output: Array ( [0] => path [1] => to [2] => folder )

$string = 'path/to/folder/';
$array = explode('/', $string, 0);
Output: Array ( [0] => path/to/folder/ )

Expected result:
array explode(string $delimiter, string $string [, int $limit])

Actual result:
array explode(string $delimiter, string $string [, int $limit = -1])


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-01 17:30 UTC]
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]
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-2021 The PHP Group
All rights reserved.
Last updated: Fri Oct 22 01:03:33 2021 UTC