3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "abc, abcd, aec, abc, aaa, ccc, aec, abc, efg, abc, aaa, aec, cde"; $array = explode(',', $string); //Trim it up first. $array = array_map(function($item){ return trim($item); }, $array); $array = array_reduce($array, function($carry, $item){ if(isset($carry[$item])) { $carry[$item]++; } else { $carry[$item] = 1; } return $carry; }); var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { ["abc"]=> int(4) ["abcd"]=> int(1) ["aec"]=> int(3) ["aaa"]=> int(2) ["ccc"]=> int(1) ["efg"]=> int(1) ["cde"]=> int(1) }

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:
58.57 ms | 405 KiB | 5 Q