php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40769 array_diff() doesn't compare booleans
Submitted: 2007-03-09 20:34 UTC Modified: 2007-03-09 23:55 UTC
From: phpreport at alecweb dot be Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.1 OS: MacOSX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpreport at alecweb dot be
New email:
PHP Version: OS:

 

 [2007-03-09 20:34 UTC] phpreport at alecweb dot be
Description:
------------
array_diff doesn't compare booleans.


Reproduce code:
---------------
$array1 = Array
(
    [domains] => 300
    [subdomains] => 120
    [cgi] => 
    [php] => 
    [safemode] => 1
)
$array2 = Array
(
    [domains] => 300
    [subdomains] => 120
    [cgi] => 1
    [php] => 1
    [safemode] => 
)
 

$arrayres = array_diff($array1, $array2);


Expected result:
----------------
this is a vardump of $array1, $array2 and $arrayres

array(5) {
  ["domains"]=>
  string(3) "300"
  ["subdomains"]=>
  string(3) "120"
  ["cgi"]=>
  bool(false)
  ["php"]=>
  bool(false)
  ["safemode"]=>
  bool(true)
}
array(5) {
  ["domains"]=>
  string(3) "300"
  ["subdomains"]=>
  string(3) "120"
  ["cgi"]=>
  bool(true)
  ["php"]=>
  bool(true)
  ["safemode"]=>
  bool(false)
}
array(0) {
  ["cgi"]=>
  bool(false)
  ["php"]=>
  bool(false)
  ["safemode"]=>
  bool(true)
}

Actual result:
--------------
this is a vardump of $array1, $array2 and $arrayres

array(5) {
  ["domains"]=>
  string(3) "300"
  ["subdomains"]=>
  string(3) "120"
  ["cgi"]=>
  bool(false)
  ["php"]=>
  bool(false)
  ["safemode"]=>
  bool(true)
}
array(5) {
  ["domains"]=>
  string(3) "300"
  ["subdomains"]=>
  string(3) "120"
  ["cgi"]=>
  bool(true)
  ["php"]=>
  bool(true)
  ["safemode"]=>
  bool(false)
}
array(0) {
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-09 23:55 UTC] tony2001@php.net
http://php.net/array_diff

array_diff() - returns an array containing all the values of array1 that are not present in any of the other arguments.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 11:01:27 2024 UTC