php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67927 in_array returns false searching for the word 'array'
Submitted: 2014-08-28 20:59 UTC Modified: 2014-08-28 21:04 UTC
From: jhackwell at docmagic dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.6.0 OS: Centos 6.5
Private report: No CVE-ID: None
 [2014-08-28 20:59 UTC] jhackwell at docmagic dot com
Description:
------------
The in_array function does not seem to be able to find the word 'array' inside an array.

Test script:
---------------
$arr = array(
    '​array',
);

echo in_array('array', $arr) ? 'it\'s there' : 'it\'s not there';

Expected result:
----------------
it's there

Actual result:
--------------
it's not there

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-28 21:00 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2014-08-28 21:00 UTC] aharvey@php.net
You have a non-breaking space at the start of the 'array' in your $arr definition, hence the in_array() fails.
 [2014-08-28 21:04 UTC] jhackwell at docmagic dot com
Good catch.  The word had been copy-pasted from elsewhere, so I didn't notice. Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 08:01:30 2024 UTC