php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70668 array_keys() doesn't respect references when $strict is true
Submitted: 2015-10-08 11:51 UTC Modified: 2015-10-08 11:52 UTC
From: dmitry@php.net Assigned: dmitry (profile)
Status: Closed Package: Arrays related
PHP Version: 7.0Git-2015-10-08 (Git) OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dmitry@php.net
New email:
PHP Version: OS:

 

 [2015-10-08 11:51 UTC] dmitry@php.net
Description:
------------
Comparison of references doesn't work properly when $strict argument is true.

Test script:
---------------
<?php
$arr = array(1, "1", "", NULL, 0, false, true, array());

$s = &$arr[0];
var_dump(array_keys($arr, $s, true));

$s = &$arr[1];
var_dump(array_keys($arr, $s, true));

$s = &$arr[2];
var_dump(array_keys($arr, $s, true));

$s = &$arr[3];
var_dump(array_keys($arr, $s, true));

$s = &$arr[4];
var_dump(array_keys($arr, $s, true));

$s = &$arr[5];
var_dump(array_keys($arr, $s, true));

$s = &$arr[6];
var_dump(array_keys($arr, $s, true));

$s = &$arr[7];
var_dump(array_keys($arr, $s, true));
?>


Expected result:
----------------
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(2)
}
array(1) {
  [0]=>
  int(3)
}
array(1) {
  [0]=>
  int(4)
}
array(1) {
  [0]=>
  int(5)
}
array(1) {
  [0]=>
  int(6)
}
array(1) {
  [0]=>
  int(7)
}


Actual result:
--------------
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-08 11:52 UTC] dmitry@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2015-10-08 12:00 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3815e9713601a637b30bb99d631fc68df97f9288
Log: Fixed bug #70668 (array_keys() doesn't respect references when $strict is true)
 [2015-10-08 12:00 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2015-10-13 10:12 UTC] ab@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3815e9713601a637b30bb99d631fc68df97f9288
Log: Fixed bug #70668 (array_keys() doesn't respect references when $strict is true)
 [2016-07-20 11:36 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3815e9713601a637b30bb99d631fc68df97f9288
Log: Fixed bug #70668 (array_keys() doesn't respect references when $strict is true)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC