note 69379 rejected from function.in-array by betz

From: Date: Sun, 03 Sep 2006 20:22:40 +0000
Subject: note 69379 rejected from function.in-array by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116646@lists.php.net to get a copy of this message
Note Submitter: sabainabukhari at yahoo dot com ---- I didn't find this anywhere in the manual or in the notes. I'm sorry if this is a repetition, but I just found this out the hard way :( If the haystack array contains only ONE element, then in_array will give this warning: Wrong datatype for second argument in call to in_array() This can be fixed by explicitly typecasting the haystack array to an array. <? $haystack = (array) $haystack; if(in_array($needle, $haystack)) return true; else return false; ?>

« previous php.notes (#116646) next »