|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78964 Third parameter of array_slice() is int type but with NULL default
Submitted: 2019-12-15 18:30 UTC Modified: 2019-12-29 04:22 UTC
From: kjell dot eikland at online dot no Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 7.4.0 OS: Win
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kjell dot eikland at online dot no
New email:
PHP Version: OS:


 [2019-12-15 18:30 UTC] kjell dot eikland at online dot no
I need to have keys returned in an array_slice() operation where I remove some n first elements and keep the rest.  That means that the third parameter must be NULL and the fourth is TRUE. 

The third parameter is defined to be of type int, with a default of NULL.  I get non-fatal error messages when specifying a NULL parameter value to override the default for the fourth parameter. 

Test script:
$arr = ['a' => 45, 'b' => 30];
$exp = array_slice($exp, 1, null, true);

Expected result:
$exp = ['b' => 30] and no debug error message returned.

Actual result:
$exp = ['b' => 30] and error message returned.
Severity	Code	Description	Project	File	Line	Suppression State
Warning	PHP0406	Argument '3' passed to array_slice() is expected to be of type int, null given	... 	


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-15 21:45 UTC]
-Status: Open +Status: Feedback -Type: Documentation Problem +Type: Bug -Package: *General Issues +Package: Arrays related
 [2019-12-15 21:45 UTC]
Works for me.
 [2019-12-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 22:01:29 2023 UTC