note 75263 added to function.in-array

From: Date: Mon, 21 May 2007 03:48:18 +0000
Subject: note 75263 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-126783@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 87.124.64.96 Probable Submitter: 86.3.34.197 ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- https://master.php.net/note/edit/75263 Del: integrated -- https://master.php.net/note/delete/75263/integrated Del: useless -- https://master.php.net/note/delete/75263/useless Del: bad code -- https://master.php.net/note/delete/75263/bad+code Del: spam -- https://master.php.net/note/delete/75263/spam Del: non-english -- https://master.php.net/note/delete/75263/non-english Del: in docs -- https://master.php.net/note/delete/75263/in+docs Del: other reasons-- https://master.php.net/note/delete/75263 Reject -- https://master.php.net/note/reject/75263 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126783) next »