You are here: Re: retrieve array subset in random order « PHP Programming Language « IT news, forums, messages
Re: retrieve array subset in random order

Posted by Rik on 03/11/07 08:20

kevincw01 <kevin@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 =3D array(....something..);
$top =3D array_splice(0,30,$array);
shuffle($top);

Where are you getting your data from? Seems it might be better to not ha=
ve =

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация