php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11893 array_intersect doesn't handle multidimensional arrays correctly
Submitted: 2001-07-04 19:49 UTC Modified: 2001-09-14 19:35 UTC
From: michael at zaphod dot rhein-neckar dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: Linux, FreeBSD, OpenBSD (Any?)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 + 38 = ?
Subscribe to this entry?

 
 [2001-07-04 19:49 UTC] michael at zaphod dot rhein-neckar dot de
michael@zaphod:~>php
<?
$a = array(array(1, "a"), array(2, "b"), array(3, "c"));
$b = array(array(1, "a"), array(2, "b"), array(4, "d"));
$c = array_intersect($a, $b);

var_dump($c);
?>
X-Powered-By: PHP/4.0.6
Content-type: text/html

array(3) {
  [0]=>
  array(2) {
    [0]=>
    int(1)
    [1]=>
    string(1) "a"
  }
  [1]=>
  array(2) {
    [0]=>
    int(2)
    [1]=>
    string(1) "b"
  }
  [2]=>
  array(2) {
    [0]=>
    int(3)
    [1]=>
    string(1) "c"
  }
}

The same thing happens in 4.0.5.

For comparison 4.0.4pl1-Output (and as I expect it to be):

X-Powered-By: PHP/4.0.4pl1
Content-type: text/html

array(2) {
  [0]=>
  array(2) {
    [0]=>
    int(1)
    [1]=>
    string(1) "a"
  }
  [1]=>
  array(2) {
    [0]=>
    int(2)
    [1]=>
    string(1) "b"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-14 19:35 UTC] jeroen@php.net
array_intersect isn't supposed to handle multi-dimmed arrays.

Where have you read that? Not in the manual in any case.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 13:01:29 2024 UTC