note 33012 modified in function.array-rand by vrana

From: Date: Tue, 17 Aug 2004 14:48:42 +0000
Subject: note 33012 modified in function.array-rand by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79775@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: <?php $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]]} } ?> --was-- 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]]} } http://php.net/manual/en/function.array-rand.php

« previous php.notes (#79775) next »