@ 2019-02-12T19:46:40Z <?php
$max = 100; // The last number
$cols = 5; // The point at which a new line will start
$arr = array_chunk(range(1, $max), $cols); // Magic ;D
// Print the data.
foreach ($arr as $key => $row) {
// This will reverse every other row
$row = ($key % 2 === 0) ? $row : array_reverse($row);
foreach ($row as $value) {
$value = str_pad($value, strlen($max), ' ', STR_PAD_LEFT);
echo "{$value} ";
}
echo "\n";
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
30 29 28 27 26
31 32 33 34 35
40 39 38 37 36
41 42 43 44 45
50 49 48 47 46
51 52 53 54 55
60 59 58 57 56
61 62 63 64 65
70 69 68 67 66
71 72 73 74 75
80 79 78 77 76
81 82 83 84 85
90 89 88 87 86
91 92 93 94 95
100 99 98 97 96
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
30 29 28 27 26
31 32 33 34 35
40 39 38 37 36
41 42 43 44 45
50 49 48 47 46
51 52 53 54 55
60 59 58 57 56
61 62 63 64 65
70 69 68 67 66
71 72 73 74 75
80 79 78 77 76
81 82 83 84 85
90 89 88 87 86
91 92 93 94 95
100 99 98 97 96
preferences:dark mode live preview
144.15 ms | 403 KiB | 156 Q