|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70466 in_array("a", array(0, 1) does not work properly
Submitted: 2015-09-09 02:23 UTC Modified: 2015-09-09 02:44 UTC
From: besciualexandru at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Arrays related
PHP Version: Next Minor Version OS: CENTOS 5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
45 + 5 = ?
Subscribe to this entry?

 [2015-09-09 02:23 UTC] besciualexandru at gmail dot com
From manual page:
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)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-09 02:44 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2015-09-09 02:44 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

in_array() does weak comparison by default, and 'a' == 0.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Mar 07 10:01:22 2021 UTC