php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62903 array_slice ignores preserve_keys with no length
Submitted: 2012-08-23 06:18 UTC Modified: 2012-08-23 06:56 UTC
From: php at nobswolf dot info Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.3.16 OS: windows
Private report: No CVE-ID: None
 [2012-08-23 06:18 UTC] php at nobswolf dot info
Description:
------------
I want to slice an array into a first one with the first 3 entries
and a second one with the rest (variable length).

Test script:
---------------
$wertA2 = array_slice ($wertA, 0, 3, true);	
$wertA3 = array_slice ($wertA, 3, null, true);		




Expected result:
----------------
I need preserved keys even when I can not give a length.

Actual result:
--------------
The preserve_keys = true gets ignored and keys a get renumbered :-(

see also #41686

This bug is 5 years old. When will it get fixed?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-23 06:52 UTC] php at nobswolf dot info
no its not...

the problem is a later  array_merge, which does not have the option of preserve_keys

my fault, sorry

maybe every "reorder"-function should have this option
 [2012-08-23 06:53 UTC] reeze dot xia at gmail dot com
I don't get it. could you please supply full test script.


Look at this. perserver_keys works.
http://3v4l.org/hCVAv#v524

and  #4168 was marked at fixed.

Do I missing something?
 [2012-08-23 06:56 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2012-08-23 06:56 UTC] aharvey@php.net
Not a bug, per the first comment.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 01:01:30 2024 UTC