|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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: Sat Apr 10 15:01:23 2021 UTC