Jump to content

Random array?


devWhiz

Recommended Posts

I dont know how to word this really. what I want to do is

 


$Var[] = 3;
$Var[] = 6;
$Var[] = 2;
$Var[] = 17;

for($i=0; $i!=count($Var); $i++)
{
echo "#$i: ".$Var[$i]."\n";
}

 

 

I know I might be able to use rand() but I need it to echo ALL of the variables in the array in a random order, I know if I use count to find out how many variables there are that it would echo them 4 times randomly but might echo the same variable 2 times making it to where it only echos 3 different varables, if I am being confusing please let me know, I just want to get this resolved, thanks!

 

 

 

Link to comment
Share on other sites

what about this

 


for($abc=1; $abc<25; $abc++)
{
$ABC1 = rand($abc);
$ABC1 = $ABC2;

echo $ABC1 . " " . $ABC2."\n";
}

 

when I want to randomize abc1 but I want it to make abc2 randomized also but not different than abc1

Link to comment
Share on other sites

lol oops, how can I randomize the number of the for loop?

 

like

 


for($abc=1; $abc!=25; $abc++)
{
echo $array[$abc][0]. " " .$array[$abc][1];
}

I need to randomize abc but it has to be the same for each time it echos the array, make sense?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.