note 21310 deleted from function.in-array by googleguy

From: Date: Tue, 22 Oct 2013 09:01:59 +0000
Subject: note 21310 deleted from function.in-array by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196840@lists.php.net to get a copy of this message
Note Submitter: one at groobo dot com ---- 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: <?php 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.

« previous php.notes (#196840) next »