php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41396 array_reverse -> preserve keys switch not working
Submitted: 2007-05-15 10:46 UTC Modified: 2007-05-24 01:00 UTC
Votes:5
Avg. Score:4.6 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: dave at emaildienst dot de Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 5.2.2 OS: Debian Etch
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dave at emaildienst dot de
New email:
PHP Version: OS:

 

 [2007-05-15 10:46 UTC] dave at emaildienst dot de
Description:
------------
when doing an array reverse with the "preserve keys" switch, just the 
values should be reversed. in fact it makes no difference if the 
preserve keys switch is true or not.

Reproduce code:
---------------
$array[0] = 3;
$array[1] = 1;
$array[2] = 2;

$firsNewArray=array_reverse($array);
$secondNewArray=array_reverse($array, true);


Expected result:
----------------
$firstNewArray
(
    [2] => 2
    [1] => 1
    [0] => 3
)

$secondNewArray
(
    [0] => 2
    [1] => 1
    [2] => 3
)

Actual result:
--------------
$firstNewArray
(
    [2] => 2
    [1] => 1
    [0] => 3
)

$secondNewArray
(
    [2] => 2
    [1] => 1
    [0] => 3
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-16 12:57 UTC] tony2001@php.net
Cannot reproduce. This is what I get:

array(3) {
  [0]=>
  int(2)
  [1]=>
  int(1)
  [2]=>
  int(3)
}
array(3) {
  [2]=>
  int(2)
  [1]=>
  int(1)
  [0]=>
  int(3)
}

 [2007-05-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC