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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 20:01:32 2024 UTC