3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_chunk_vertical($data, $columns = 2) { $n = count($data) ; $per_column = floor($n / $columns) ; $rest = $n % $columns ; // The map $per_columns = array( ) ; for ( $i = 0 ; $i < $columns ; $i++ ) { $per_columns[$i] = $per_column + ($i < $rest ? 1 : 0) ; } $tabular = array( ) ; foreach ( $per_columns as $rows ) { for ( $i = 0 ; $i < $rows ; $i++ ) { $tabular[$i][ ] = array_shift($data) ; } } return $tabular ; } $cars = [ [ 'make' => 'Alfa Romeo', 'id' => 2 ], [ 'make' => 'Aston Martin', 'id' => 3 ], [ 'make' => 'Audi', 'id' => 4 ], [ 'make' => 'BMW', 'id' => 8 ], [ 'make' => 'Caterham', 'id' => 9 ], ]; echo '<table>'; foreach(array_chunk_vertical($cars,4) as $row) { echo '<tr>'; foreach($row as $car) { echo '<td><input type="checkbox" value="', $car['id'], '" />', $car['make'], '</td>'; } echo '</tr>'; } echo '</table>';
Output for git.master, git.master_jit, rfc.property-hooks
<table><tr><td><input type="checkbox" value="2" />Alfa Romeo</td><td><input type="checkbox" value="4" />Audi</td><td><input type="checkbox" value="8" />BMW</td><td><input type="checkbox" value="9" />Caterham</td></tr><tr><td><input type="checkbox" value="3" />Aston Martin</td></tr></table>

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:
46.04 ms | 401 KiB | 8 Q