#44213 [Opn->Bgs]: in_array returns wrong value

From: Date: Fri, 22 Feb 2008 12:37:14 +0000
Subject: #44213 [Opn->Bgs]: in_array returns wrong value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122577@lists.php.net to get a copy of this message
ID: 44213 Updated by: felipe@php.net Reported By: markus dot kalkbrenner at arcor dot de -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux PHP Version: 5.2.5 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 This result is expected. In "a" == 0, "a" is converted to int. For strict comparison, use the third parameter. http://docs.php.net/in-array Previous Comments: ------------------------------------------------------------------------ [2008-02-22 12:24:14] markus dot kalkbrenner at arcor dot de Description: ------------ in_array() returns true if needle exists as key with int(0) as value, but should return false because needle doesn't exist as value. Reproduce code: --------------- <?php var_dump( in_array('a', array('a' => 1) ) ); var_dump( in_array('a', array('a' => 0) ) ); ?> Expected result: ---------------- bool(false) bool(false) Actual result: -------------- bool(false) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44213&edit=1

« previous php.bugs (#122577) next »