note 33012 added to function.array-rand

From: Date: Fri, 13 Jun 2003 18:31:05 +0000
Subject: note 33012 added to function.array-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-50300@lists.php.net to get a copy of this message
If you use array_rand with num_req=1, it will return an integer, and not an array as it would in all other circumstances. You can bypass that like this: $randelts=array_rand($feeds,$num); for ($j=0;$j<count($randelts);$j++) { if ($num==1) {$subq[$j]=$feeds[$randelts];} else {$subq[$j]=$feeds[$randelts[$i]]} } ---- Manual Page -- http://www.php.net/manual/en/function.array-rand.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33012 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33012&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33012&report=yes

« previous php.notes (#50300) next »