|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75750 PHP 7.2.0RC3 (cli) (built: Sep 28 2017 16:28:14) ( NTS )
Submitted: 2017-12-30 22:48 UTC Modified: 2017-12-30 22:59 UTC
From: helldar at ai-rus dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.2.0 OS: Irrelevant
Private report: No CVE-ID: None
 [2017-12-30 22:48 UTC] helldar at ai-rus dot com
When searching for an integer "0" in the in_array function that does not contain it as a value, the function always returns true

PHP 7.2.0RC3 (cli) (built: Sep 28 2017 16:28:14) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.2.0RC3, Copyright (c) 1999-2017, by Zend Technologies
    with blackfire v1.18.0~linux-x64-non_zts72,, by SensioLabs

Test script:
$arr = ['Car', 'Images'];
$key = 0;

echo (string)in_array($key, $arr);
// Returned: 1


$arr = ['Car', 'Images'];
$key = 1;

echo (string)in_array($key, $arr);
// Returned: 0


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-30 22:52 UTC] helldar at ai-rus dot com
The bug works in the following versions of PHP: 5.6.29, 7.0.14, 7.1.12 and 7.2.0RC3.
Other versions I did not check.
 [2017-12-30 22:59 UTC]
-Status: Open +Status: Not a bug
 [2017-12-30 22:59 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
> Searches haystack for needle using loose comparison unless strict is set.

Use in_array($key, $arr, true).
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 13:01:26 2020 UTC