3v4l.org

run code in 300+ PHP versions simultaneously
<?php $posts = array('post1', 'post2', 'post3', 'post4', 'post5', 'post6', 'post7', 'post8', 'post9'); // one foreach to divide posts $col = 1; foreach($posts as $post) { $cols[$col][] = $post; $col = $col == 4 ? 1 : $col+1; } var_dump($cols); die(); // then, another foreach for the html foreach($cols as $col) { // open col div echo "<div>"; foreach($col as $post) { // print post echo "$post,"; } // close col div echo "</div>"; }
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [1]=> array(3) { [0]=> string(5) "post1" [1]=> string(5) "post5" [2]=> string(5) "post9" } [2]=> array(2) { [0]=> string(5) "post2" [1]=> string(5) "post6" } [3]=> array(2) { [0]=> string(5) "post3" [1]=> string(5) "post7" } [4]=> array(2) { [0]=> string(5) "post4" [1]=> string(5) "post8" } }

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:
39.75 ms | 402 KiB | 8 Q