Bug #51781 [Opn->Bgs]: array index 0 problem

From: Date: Mon, 10 May 2010 08:57:53 +0000
Subject: Bug #51781 [Opn->Bgs]: array index 0 problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150299@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51781&edit=1

 ID:               51781
 Updated by:       johannes@php.net
 Reported by:      feng_evan at yahoo dot com
 Summary:          array index 0 problem
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Arrays related
 Operating System: windows xp
 PHP Version:      5.2.13

 New Comment:

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

numeric indexes are stored as integers, comparing integer 0 with a
string not starting with a digit gives true as the string is casted to
an integer.

Expected, documented, behavior. Won't change.


Previous Comments:
------------------------------------------------------------------------
[2010-05-10 09:35:52] feng_evan at yahoo dot com

Description:
------------
Array index value judgments must use absolute equal?

Test script:
---------------
$arr = array();
$arr['0'] = 'zero';
$arr['keyword'] = 'keyword';
foreach($arr as $key => $val) {
    if ($key == 'keyword') {
    //if ($key === 'keyword') { //ok
        echo $val."\n";
    }
}
//output:zero keyword



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



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51781&edit=1


Thread (4 messages)

« previous php.bugs (#150299) next »