|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: besciualexandru at gmail dot com
New email:
PHP Version: OS:


 [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: Thu Jan 21 12:01:23 2021 UTC