3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Gridizer { /** * Get a squar-ish grid */ public function getGrid($array) { $grid_size = floor(sqrt(count($array))); $table = $this->chunk($table_cells, max($grid_size, 1)); foreach ($table as $row) { echo implode(' | ', $row) . PHP_EOL; } } /** * Create a Generator to chunk an incoming array into `$chunk_size` sized chunks */ 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 Gridizer; echo $foo->getGrid(range(1, 100));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $table_cells in /in/TGhWR on line 12 Fatal error: Uncaught TypeError: Gridizer::chunk(): Argument #1 ($array) must be of type array, null given, called in /in/TGhWR on line 12 and defined in /in/TGhWR:22 Stack trace: #0 /in/TGhWR(12): Gridizer->chunk(NULL, 10.0) #1 /in/TGhWR(34): Gridizer->getGrid(Array) #2 {main} thrown in /in/TGhWR on line 22
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.87 ms | 401 KiB | 8 Q