Bug #17655: key and intval on associative array are equal

From: Date: Sat, 08 Jun 2002 13:04:03 +0000
Subject: Bug #17655: key and intval on associative array are equal
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-9843@lists.php.net to get a copy of this message
From: msopacua@idg.nl Operating system: Any PHP version: 4.2.1 PHP Bug Type: Arrays related Bug description: key and intval on associative array are equal Sample: <?php $arr = array( 'string' => 'a string', 'anotherstring' => 'b string' ); print(key($arr)."\t"); print(intval(key($arr))."\n"); if(key($arr) == intval(key($arr))) { print("Equal!\n"); } else { print("Not equal\n"); } if(key($arr) === intval(key($arr))) { print("Equal!\n"); } else { print("Not equal\n"); } ?> Output: string 0 Equal! Not equal That really defeats the use of intval(). Confirmed on BSD/OS and Native windows/isapi. -- Edit bug report at http://bugs.php.net/?id=17655&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=17655&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=17655&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=17655&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=17655&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=17655&r=support Expected behavior: http://bugs.php.net/fix.php?id=17655&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=17655&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=17655&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=17655&r=globals

« previous php.bugs (#9843) next »