php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23076 in_array generates error when using object as needle
Submitted: 2003-04-06 21:06 UTC Modified: 2003-04-06 21:19 UTC
From: colin at omenmedia dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.1 OS: Windows 2000
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: colin at omenmedia dot com
New email:
PHP Version: OS:

 

 [2003-04-06 21:06 UTC] colin at omenmedia dot com
PHP is reporting a "Wrong datatype for first argument" error when using an object as the needle argument for the in_array() function.  The code below will generate the error:

<?php

class Foo
{
 
}

$foo = new Foo();
$test = array(1,2,3,4,5);
 
if (in_array($foo,$test))
{
   print "Yes";
}
else
{
   print "No";
}

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-26 11:41 UTC] benoit dot ferlet at freesbee dot fr
I've the same Bug in the 4.3.4 php version !

when I use in_array(Object,Array) I've the wrong data type error !
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC