3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array("bla","ble","blu","ab","bc","asdda","fju","ha","y","yi","yid"); $sorted_array = $array; natsort($sorted_array); $grouped_array = array(); foreach ($sorted_array as $item) { $letter = substr($item, 0, 1); $grouped_array[$letter][] = $item; } var_dump($grouped_array);
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { ["a"]=> array(2) { [0]=> string(2) "ab" [1]=> string(5) "asdda" } ["b"]=> array(4) { [0]=> string(2) "bc" [1]=> string(3) "bla" [2]=> string(3) "ble" [3]=> string(3) "blu" } ["f"]=> array(1) { [0]=> string(3) "fju" } ["h"]=> array(1) { [0]=> string(2) "ha" } ["y"]=> array(3) { [0]=> string(1) "y" [1]=> string(2) "yi" [2]=> string(3) "yid" } }

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