// Get random numbers loaded into array $v = array(); for ($i=0; $i<$config["showprofiles"]; $i++){ $rand=rand(0,count($images1)-1); for ($j=0; $j<$i; $j++) { if ($rand != $v[$j]) {} else echo "need to make loop to generate a new number"; // if all fields in array have been verified as unique then set this field. if ($j=$i) {$v[$i]=$rand;}} return $v; }