php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24829 array_intersect_assoc compares keys AND values
Submitted: 2003-07-27 08:34 UTC Modified: 2003-07-27 13:50 UTC
From: niklas at zim dot goe dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.1 OS: Linux 2.4.20
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: niklas at zim dot goe dot net
New email:
PHP Version: OS:

 

 [2003-07-27 08:34 UTC] niklas at zim dot goe dot net
Description:
------------
The function array_intersect_assoc compares keys AND values. According to the documentation only the keys should be considered.

The documentation says:
"Note that the keys are used in the comparison unlike in array_intersect()."

If this is the volitional behavior you should point that out in the documentation ("... that the keys are used too ...").

Reproduce code:
---------------
$array1 = array ("a" => "green");
$array2 = array ("a" => "greenToo");
print_r(array_intersect_assoc ($array1, $array2));

Expected result:
----------------
Array(
  [a] => "green"
)

Actual result:
--------------
Array()


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-27 10:03 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The displayed behaviour is the correct one.
 [2003-07-27 13:50 UTC] niklas at zim dot goe dot net
Maybe you can point this out in the documentation.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC