$limit = 9; $minNumber =1; $maxNumber =9; $numbers = array (); for ( $x = 1; $x <= $limit; $x ++ ){ $numbers[$x] = rand($minNumber,$maxNumber); foreach($numbers as $var=>$val){ $$var = $val; } echo $var . " = " . $val . "<br>"; } PHP: output: 1 = 2 2 = 1 3 = 7 4 = 9 5 = 1 6 = 2 7 = 7 8 = 3 9 = 3 99 99?? WTF can you explain that to a rook? what i want is thisi know the foreach should not be in the for statement. but i am lost. noob here 1 = 2 2 = 1 3 = 7 4 = 9 5 = 1 6 = 2 7 = 7 8 = 3 9 = 3 ps wtf formatting!!!!
Fixed. Thanks anyway $limit = 9; $minNumber =1; $maxNumber =9; $numbers = array (); for ( $x = 1; $x <= $limit; $x ++ ){ $string = 'img'.$x; $$string = rand($minNumber,$maxNumber); } for($x = 1; $x <= $limit; $x ++){ $string = 'img'.$x; //echo $x . " = " . $$string . "<br>"; } PHP: