//this function generates the distinct random numbers for the 25 requirment
function unique_rand_numbers($numbers)
{
 for($i = 1; $i = 40; $i++)
 {
	$numbers = $i;
 }
 $array = array();
 
 //get unique random keys from $numbers array.
 $rand_keys = array_rand($numbers,25);
 
 //this sorts the distinct random numbers taken from $numbers in random order.
 sort($rand_keys);

 //stuck on this part..i need to store more than one value here
//theres 25 intergers in $rand_numbers..i'd a ppricaite any help.

 $array[][] = $rand_numbers;
 
 return $rand_numbers;
 }
Member Avatar for diafol
<?php
function unique_rand_numbers($min=1,$max=40,$inc=1,$num=25){
 $rand_keys = array_rand(range($min,$max,$inc),$num);
 sort($rand_keys);
 return $rand_keys;
}

print_r(unique_rand_numbers());
echo "<br /><br /><br />";
print_r(unique_rand_numbers(1,50,1,6));
?>

If you need a list of numbers in an array, range() can save some time. I've included optional parameters in the function, but you can take these out and hardcode your values if you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.