3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooTable { public function getTable() { $table_cells = range(1, 100); $table = $this->chunk($table_cells, 10); foreach ($table as $row) { echo implode(' | ', $row) . PHP_EOL; } } public function chunk(array $array, $chunk_size) { $index = 0; while ($index < count($array)) { yield array_slice($array, $index, $chunk_size, true); $index += $chunk_size; } } } $foo = new FooTable; echo $foo->getTable();
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 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.6
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected 'array_slice' (T_STRING) in /in/3SZpe on line 20
Process exited with code 255.

preferences:
256.82 ms | 401 KiB | 375 Q