note 94093 deleted from function.array-rand by danbrown

From: Date: Thu, 15 Oct 2009 21:58:51 +0000
Subject: note 94093 deleted from function.array-rand by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161793@lists.php.net to get a copy of this message
Note Submitter: Yousha at YPY dot ir ---- Faster than all Random array(Element) functions in this PAGE: # Copyright Y.P.Y & http://forum.IranPHP.ORG function Random_Element($Ary_Input, $Int_Count) { if(count(&$Ary_Input) >= $Int_Count): return($Ary_Input); endif; do { for($i = 0; $i < $Int_Count; $i ++): $_Ary_Output[]= $Ary_Input[array_rand(&$Ary_Input)]; endfor; $_Ary_Output= array_unique($_Ary_Output); if(count(&$_Ary_Output) == $Int_Count): break; else: unset($_Ary_Output); endif; } while(count(&$_Ary_Output) < $Int_Count); return($_Ary_Output); } Enjoy ;).

« previous php.notes (#161793) next »