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
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: jhackwell at docmagic dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 01:01:34 2025 UTC