Menu
I’m trying to get a random picture script that I wrote working right, but i’m having some issues with it repeating. Basically this script generates 16 random numbers between 1 and 149. I then check to make sure the number isn’t already in the array (this is the part thats not working), and if its not, i add it to the array. basically, my pictures are named 001.jpg – 149.jpg
[code=php]$numpics=149;
$array=array();
$pics=array_pad($array,16,0);
for($i=1;$i<20;$i++)
{
$temp=str_pad(rand(1,$numpics),3,”0″,PAD_LEFT);
while(array_search($temp,$pics)<0){$temp=str_pad(rand(1,$numpics),3,”0″,PAD_LEFT);}
$pics[$i]=$temp;
}