php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49167 Bug in in_array() function
Submitted: 2009-08-05 07:43 UTC Modified: 2009-08-05 07:53 UTC
From: dos at null-squad dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.3.0 OS: CentOS
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dos at null-squad dot com
New email:
PHP Version: OS:

 

 [2009-08-05 07:43 UTC] dos at null-squad dot com
Description:
------------
in_array() returns true for in_array('a', array('a'=>true)) instead of 
false.

Reproduce code:
---------------
var_dump(
    in_array(
        'a',
        array('a'=>true)
    )
);

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-05 07:53 UTC] jani@php.net
It's same as this: "a" == true. Which you fix with "a" === true.
Use the 3rd param, Luke. RTFM: http://php.net/in_array
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 14:01:31 2025 UTC