note 21310 added to function.in-array

From: Date: Tue, 07 May 2002 19:14:21 +0000
Subject: note 21310 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-30304@lists.php.net to get a copy of this message
Sometimes, you might want to search values in array, that does not exist. In this case php will display nasty warning: Wrong datatype for second argument in call to in_array() . In this case, add a simple statement before the in_array function: if (sizeof($arr_to_searchin) == 0 || !in_array($value, $arr_to_searchin)) { ... } In this case, the 1st statement will return true, omitting the 2nd one. -- http://www.php.net/manual/en/function.in-array.php http://master.php.net/manage/user-notes.php?action=edit+21310 http://master.php.net/manage/user-notes.php?action=delete+21310 http://master.php.net/manage/user-notes.php?action=reject+21310

« previous php.notes (#30304) next »