note 75263 deleted from function.in-array by cmb

From: Date: Mon, 21 Jan 2019 14:23:39 +0000
Subject: note 75263 deleted from function.in-array by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210092@lists.php.net to get a copy of this message
Note Submitter: Quaquaversal ---- A simple function to type less when wanting to check if any one of many values is in a single array. <?php function array_in_array($needle, $haystack) { //Make sure $needle is an array for foreach if(!is_array($needle)) $needle = array($needle); //For each value in $needle, return TRUE if in $haystack foreach($needle as $pin) if(in_array($pin, $haystack)) return TRUE; //Return FALSE if none of the values from $needle are found in $haystack return FALSE; } ?>

« previous php.notes (#210092) next »