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.
Thanks 4 2256
kevincw01 <ke***@netkev.comwrote:
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
On Mar 11, 12:20 am, Rik <luiheidsgoe...@hotmail.comwrote:
kevincw01 <k...@netkev.comwrote:
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?
On Mar 11, 12:38 am, "kevincw01" <k...@netkev.comwrote:
On Mar 11, 12:20 am, Rik <luiheidsgoe...@hotmail.comwrote:
kevincw01 <k...@netkev.comwrote:
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?
Wait I see the problem. That's the incorrect array_splice syntax.
Correct is array_splice($array,first_index,last_index). Works well
now.
kevincw01 <ke***@netkev.comwrote:
Wait I see the problem. That's the incorrect array_splice syntax.
Correct is array_splice($array,first_index,last_index). Works well
now.
Oops, still early for a sunday morning :P
--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael Drumheller |
last post by:
(If you're not interested in NumArray, please skip this message.)
I am new to NumArray and I wonder if someone can help me with
array-indexing. Here's the basic situation: Given a rank-2 array...
|
by: Chris Dutrow |
last post by:
I searched around on the net for a bit, couldn't find anything though.
I would like to find some code for a function where I input A Range Of
Integers
For example: Function( 1, 100 );
And the...
|
by: gl |
last post by:
How do I take an array or arraylist, and sort it randomly? Like suppose the
items in it are (1,2,3,4,5) and I want to get it to be in a random order
(2,3,1,4,5). How do you do that? I think it's a...
|
by: yeti349 |
last post by:
Hi, I'm using the following code to retrieve data from an xml file and
populate a javascript array. The data is then displayed in html table
form. I would like to then be able to sort by each...
|
by: Paul van Brenk |
last post by:
When you run the Shuffle method often enough it will throw exception.
And I can't figure out why.
Anybody?
Paul van Brenk
the code:
static void Shuffle(){
int ints = { 1, 2, 3, 4, 5, 6,...
|
by: jar13861 |
last post by:
I'm confused on how to write a random array that will only generate 9
different numbers from 1-9. Here is what I have, but its only writing
one number....
holder = new Array ( 9 );
var flag =...
|
by: Jeremy |
last post by:
I have a situation where i am trying to run two query's and retrieve
one record from each query, then using Union combine them into one
recordset. The First Query is strait forward and should just...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: Tuxedo |
last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any
elements thereafter in an array in random order:
var a = new...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |