#40769 [NEW]: array_diff() doesn't compare booleans

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40769 [NEW]: array_diff() doesn't compare booleans

    From: phpreport at alecweb dot be
    Operating system: MacOSX
    PHP version: 5.2.1
    PHP Bug Type: Arrays related
    Bug description: array_diff() doesn't compare booleans

    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) {
    }

    --
    Edit bug report at http://bugs.php.net/?id=40769&edit=1
    --
    Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40769&r=trysnapshot44
    Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40769&r=trysnapshot52
    Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40769&r=trysnapshot60
    Fixed in CVS: http://bugs.php.net/fix.php?id=40769&r=fixedcvs
    Fixed in release: http://bugs.php.net/fix.php?id=40769&r=alreadyfixed
    Need backtrace: http://bugs.php.net/fix.php?id=40769&r=needtrace
    Need Reproduce Script: http://bugs.php.net/fix.php?id=40769&r=needscript
    Try newer version: http://bugs.php.net/fix.php?id=40769&r=oldversion
    Not developer issue: http://bugs.php.net/fix.php?id=40769&r=support
    Expected behavior: http://bugs.php.net/fix.php?id=40769&r=notwrong
    Not enough info: http://bugs.php.net/fix.php?id=40769&r=notenoughinfo
    Submitted twice: http://bugs.php.net/fix.php?id=40769&r=submittedtwice
    register_globals: http://bugs.php.net/fix.php?id=40769&r=globals
    PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40769&r=php3
    Daylight Savings: http://bugs.php.net/fix.php?id=40769&r=dst
    IIS Stability: http://bugs.php.net/fix.php?id=40769&r=isapi
    Install GNU Sed: http://bugs.php.net/fix.php?id=40769&r=gnused
    Floating point limitations: http://bugs.php.net/fix.php?id=40769&r=float
    No Zend Extensions: http://bugs.php.net/fix.php?id=40769&r=nozend
    MySQL Configuration Error: http://bugs.php.net/fix.php?id=40769&r=mysqlcfg
    phpreport at alecweb dot be Guest

  2. Similar Questions and Discussions

    1. #39811 [NEW]: array_diff "compare with 2" bug
      From: wishm at bk dot ru Operating system: win32 PHP version: 4.4.4 PHP Bug Type: Arrays related Bug description: ...
    2. #25164 [Com]: array_diff issue
      ID: 25164 Comment by: linuxfool at Hotmail dot com Reported By: linuxfool at hotmail dot com Status: Bogus Bug...
    3. #25164 [Opn->Bgs]: array_diff issue
      ID: 25164 Updated by: derick@php.net Reported By: linuxfool at hotmail dot com -Status: Open +Status: ...
    4. #25129 [Opn->Bgs]: Array_diff gives a bad result
      ID: 25129 Updated by: derick@php.net Reported By: tech at mediaforest dot net -Status: Open +Status: ...
    5. Booleans
      Okay, as a convert from Perl to Ruby, I have to say that I love just about everything Ruby has to offer. Just about. I wish it had better...
  3. #2

    Default #40769 [Opn->Bgs]: array_diff() doesn't compare booleans

    ID: 40769
    Updated by: [email]tony2001@php.net[/email]
    Reported By: phpreport at alecweb dot be
    -Status: Open
    +Status: Bogus
    Bug Type: Arrays related
    Operating System: MacOSX
    PHP Version: 5.2.1
    New Comment:

    [url]http://php.net/array_diff[/url]

    array_diff() - returns an array containing all the values of array1
    that are not present in any of the other arguments.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-09 20:34:44] 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) {
    }


    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=40769&edit=1
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139