|  | Posted by kevincw01 on 03/11/07 08:38 
On Mar 11, 12:20 am, Rik <luiheidsgoe...@hotmail.com> wrote:> kevincw01 <k...@netkev.com> wrote:
 > > Anyone have a clever way to retrieve for example, items 0-29 from an
 > > array of size N>29, in random order?  The catch is that I dont want to
 > > print any items more than once and I dont want to miss any.
 >
 > > This is for a tag cloud where I have sorted them by popularity but now
 > > I need to display only the top 30.  I do this now but they are in
 > > order of popularity and its not really a 'cloud'.  If I could retrieve
 > > the top 30 in some random order, it would look better.
 >
 > $array = array(....something..);
 > $top = array_splice(0,30,$array);
 > shuffle($top);
 >
 > Where are you getting your data from? Seems it might be better to not have
 > this in the array to begin with.
 > --
 > Rik Wasmus
 > Posted on Usenet, not any forum you might see this in.
 > Ask Smart Questions:http://tinyurl.com/anel
 
 Interesting, I'm getting the famous array reference error with that
 code(first line below):
 <?php $top = array_splice(0,$tags2show,$tags); ?>
 <?php shuffle($top); ?>
 
 Fatal Error: Only variables can be passed by reference...
 
 The fix should be to store function array results in a temp variable
 but I don't see where I'm not doing that?
 [Back to original message] |