php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73205 Default value for $length is shown as 0, but it it not
Submitted: 2016-09-30 01:15 UTC Modified: 2016-10-04 10:02 UTC
From: nick at nickduffell dot com dot au Assigned: cmb (profile)
Status: Closed Package: Arrays related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2016-09-30 01:15 UTC] nick at nickduffell dot com dot au
Description:
------------
---
From manual page: http://www.php.net/function.array-splice
---

Default value for $length is shown as 0, but it should be null.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-30 08:16 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: Website problem +Package: Arrays related -Assigned To: +Assigned To: cmb
 [2016-09-30 08:16 UTC] cmb@php.net
No, `0` is the default value, i.e. without passing a $length, the
function behaves as if `0` was passed.
 [2016-10-04 09:36 UTC] nick at nickduffell dot com dot au
The document also states the following:
If length is specified and is zero, no elements will be removed

If zero was the default value the function would do nothing unless you passed a value into that parameter. 

When I look in my IDE however it has the following, which I believe is correct:
function array_splice (array &$input, $offset, $length = null, $replacement = null) {}
 [2016-10-04 09:53 UTC] cmb@php.net
-Summary: Default value for $length is shown as 0, but it should be null. +Summary: Default value for $length is shown as 0, but it it not -Status: Not a bug +Status: Verified
 [2016-10-04 09:53 UTC] cmb@php.net
> If length is specified and is zero, no elements will be removed

You're right. Actually, the default value is `count($input)`[1].

It's definitely not NULL, though, see <https://3v4l.org/6AAFC>.

[1] <https://github.com/php/php-src/blob/PHP-7.0.11/ext/standard/array.c#L2867-L2871>
 [2016-10-04 10:02 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=340300
Log: Fix #73205: Default value for $length is shown as 0, but it it not
 [2016-10-04 10:02 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-10-04 10:02 UTC] cmb@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.
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=c2df92e87171e3a3ece3cf0edd7ac410420459f1
Log: Fix #73205: Default value for $length is shown as 0, but it it not
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 17:01:31 2024 UTC