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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 00:01:36 2025 UTC