Im just playing with php and i wanted to make a fake lottery generator -picks 6 random numbers, which works ok... But i want it to display all six in order, how would I do that For example, $lotnumber1 = 11, $lotnumber1 = 39, $lotnumber1 = 19, $lotnumber1 = 22, $lotnumber1 = 4, $lotnumber1 = 42, I don't want it display 11,39,19,22,4,42 when i echo it out... I want it to display 4,11,19,22,39,42.. How can I do this? Thanks, James
$nums = range(1,49); $draws = 6; $balls = array(); $draw = array_rand($nums, $draws); if(!is_array($draw)) { $draw[0] = $draw; } foreach($draw as $k => $v) { $balls[] = $nums[$v]; unset($nums[$v]); } echo '<pre>'.print_r($balls, true).'</pre>'; PHP: