note 34776 added to function.in-array
| From: | hughjonesd at yahoo dot co dot uk | Date: | Wed, 06 Aug 2003 10:33:18 +0000 |
| Subject: | note 34776 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53504@lists.php.net to get a copy of this message | ||
In PHP 4.2.0, in_array() doesn't like it if you use an object as the needle:
<?
class Foo {
function ar() {echo "baz";}
}
$f = new Foo();
$a = array(1,2,3,$f);
echo in_array($f, $a);
?>
Warning: in_array(): Wrong datatype for first argument in - on line 7
Try array_search instead, I guess.
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34776
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34776&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34776&report=yes