$ m = 3; // Number of lines $ n = 5; // Number of numbers in the string It is necessary to make the generation of random numbers and sort them

$m = 3;$n = 5; for($r=0; $r<$m; $r++) { for($i=0; $i<$n; $i++) { $arr[$i] = rand(0,$n); asort($arr); foreach ($arr as $item) { print_r($item); } } echo '<br />'; } 
  • Your code - in the studio! - Edward
  • added code - can see - Elio

1 answer 1

You inserted the output into a loop in which you fill the array, so output first one number, then two, then three ...

 $m = 3; $n = 5; for($r=0; $r<$m; $r++) { // Π΄Π΅Π»Π°Π΅ΠΌ массив ΠΈΠ· n чисСл $arr = []; for($i=0; $i<$n; $i++) { $arr[] = rand(0,$n); } // сортируСм массив ΠΈ Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ asort($arr); echo implode(' ',$arr); echo "<br />\n"; }