php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13126 in_array() is type-strict by default?
Submitted: 2001-09-04 07:18 UTC Modified: 2001-09-04 18:45 UTC
From: esivertsen at atmel dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: FreeBSD
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: esivertsen at atmel dot com
New email:
PHP Version: OS:

 

 [2001-09-04 07:18 UTC] esivertsen at atmel dot com
It seems like the in_array() function has been slightly altered in this (4.0.6) release compared to 4.0.3. 

A check of an array of chars against integers fail; but it didn't in verison 4.0.3. 

example:

$char_array = array("1","2","3");

if(in_array($char_array, 2))
   $output = "FOUND";
else
   $output = "NOT FOUND";

echo $output;


----> produces the output "NOT FOUND";

Seems some typecasting is necessary this time...


              

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-04 18:45 UTC] sniper@php.net
RTFM: 

bool in_array (mixed needle, array haystack [, bool strict])

--Jani

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 15:01:27 2019 UTC