Bug #67762 [Opn->Nab]: in_array evaluates as true when it should not

From: Date: Mon, 04 Aug 2014 23:44:17 +0000
Subject: Bug #67762 [Opn->Nab]: in_array evaluates as true when it should not
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186972@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67762&edit=1 ID: 67762 Updated by: requinix@php.net Reported by: jv at vip dot ie Summary: in_array evaluates as true when it should not -Status: Open +Status: Not a bug Type: Bug Package: *General Issues PHP Version: Irrelevant 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 Fundamental bugs are easy to find when you don't read the documentation. > Searches haystack for needle using loose comparison unless strict is set. Loose comparison, where "meter" == 0. If you want a strict comparison to get "meter" !== 0 then pass $strict=true. Previous Comments: ------------------------------------------------------------------------ [2014-08-04 23:30:53] jv at vip dot ie Description: ------------ --- From manual page: http://www.php.net/function.in-array --- The result will output true, when it should output false. Yup, this is a pretty fundamental bug ;) Test script: --------------- $correct_answers = array('meter'); $my_answer = 0; echo in_array($my_answer, $correct_answers); Expected result: ---------------- false Actual result: -------------- true ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67762&edit=1

« previous php.bugs (#186972) next »