Bug #70466 [Opn->Nab]: in_array("a", array(0, 1) does not work properly

From: Date: Wed, 09 Sep 2015 02:44:09 +0000
Subject: Bug #70466 [Opn->Nab]: in_array("a", array(0, 1) does not work properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195897@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70466&edit=1 ID: 70466 Updated by: cmb@php.net Reported by: besciualexandru at gmail dot com Summary: in_array("a", array(0, 1) does not work properly -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: CENTOS 5 PHP Version: Next Minor Version -Assigned To: +Assigned To: cmb Block user comment: N Private report: N 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 in_array() does weak comparison by default, and 'a' == 0. Previous Comments: ------------------------------------------------------------------------ [2015-09-09 02:23:33] besciualexandru at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.in-array --- The script bellow does not behave properly. Only if you put '0' and '1' as strings it behaves correctly. Test script: --------------- if (in_array("a", array(0, 1) )===true){ echo "'a' is inside array(0,1)"; } else { echo "'a' is NOT inside array(0,1)"; } Expected result: ---------------- 'a' is NOT inside array(0,1) Actual result: -------------- 'a' is inside array(0,1) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70466&edit=1

« previous php.bugs (#195897) next »