php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65865 Bug in in_array function
Submitted: 2013-10-08 18:09 UTC Modified: 2013-10-08 18:14 UTC
From: fvromera at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.5.4 OS: Fedora 18
Private report: No CVE-ID: None
 [2013-10-08 18:09 UTC] fvromera at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.in-array
---

If execute the following command:

var_dump(in_array('normalize', array('text', true)));

I get the function in_array are returning true, when not 'normalize' present in the array array('text', true);

Test script:
---------------
<?php

if (in_array('normalize', array('text', true))) {
echo 'I have a bug';
} else {
echo 'All is OK';
}

?>

Expected result:
----------------
All is OK

Actual result:
--------------
I have a bug

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-08 18:14 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2013-10-08 18:14 UTC] nikic@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please set the $strict argument of in_array to true. This will make a comparison with === rather than ==. (Remember that 'normalize' == true).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 08:01:31 2024 UTC