ID: 47609 Updated by: ka...@php.net Reported By: se...@php.net -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: RHEL 5.3 PHP Version: 5.2CVS-2009-03-09 (snap) New Comment:
Expected result, see the first example on the comparison operators page: http://www.php.net/manual/en/language.operators.comparison.php Previous Comments: ------------------------------------------------------------------------ [2009-03-10 00:01:38] se...@php.net Description: ------------ Following script will print '4-FAIL' using php 5.2.9 build and today's snapshot php5.2-200903092130. Following returns true where $k = int(0), which is wrong: if ($k == 'abc') echo "3-FAIL\n"; Also confirmed this is failing on 5.1.6. Reproduce code: --------------- <?php $a = array(4); if ($a[0] != '4') echo "1-FAIL"; if ($a[0] != 4) echo "2-FAIL"; if ($a[0] == 'abc') echo "3-FAIL\n"; foreach ($a as $k => $v) { // $k is ONLY and ALWAYS ZERO (0) var_dump($k); var_dump($v); if ($k == 'abc') echo "4-FAIL\n"; if ($k === 'abc') echo "5-FAIL\n"; if ($v == 'abc') echo "6-FAIL\n"; } Expected result: ---------------- Code should not print anything. Only key is int(0) and only value is int(4) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47609&edit=1