#36329 [Opn->Bgs]: 0 as second key in array causes false equality in foreach

From: Date: Wed, 08 Feb 2006 08:03:32 +0000
Subject: #36329 [Opn->Bgs]: 0 as second key in array causes false equality in foreach
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93040@lists.php.net to get a copy of this message
ID: 36329 Updated by: helly@php.net Reported By: tbielawa at definitivellc dot com -Status: Open +Status: Bogus Bug Type: Arrays related -Operating System: linix 2.6.6 +Operating System: * -PHP Version: 5.1.2 +PHP Version: * 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 . Previous Comments: ------------------------------------------------------------------------ [2006-02-08 05:53:41] tbielawa at definitivellc dot com Description: ------------ combination of array with zero as the second key and foreach loop is causing false equality. See simple example below... ./configure --with-apxs=/work/st/daemons/apache/bin/apxs --disable-libxml --prefix=/work/st/daemons/php --with-zlib --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear Reproduce code: --------------- <?php /*>*/; $value = 'T'; $options = array('T' => 'TBD', '0' => 'Level 0', '1' => 'Level 1', '2' => 'Level 2' ); var_dump($options); echo '<br>'; foreach($options as $val => $txt) { if($value == $val) { echo "$value == $val<br>" ; } } ?> Expected result: ---------------- I expect to ONLY see T == T. Actual result: -------------- result is: T == T T == 0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36329&edit=1

« previous php.bugs (#93040) next »