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();

preferences:
49.76 ms | 402 KiB | 5 Q