3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [9,1,9,1,3,9,1,2,9]; $values = array_count_values($array); arsort($values); //var_dump($values); $result =[]; $same = []; foreach($values as $key => $val){ if(!in_array($key, array_keys($same))){ if(next($values) != $val){ $result = array_merge($result, array_fill(0, $val, $key)); }else{ $same = array_intersect($values, [$val]); Ksort($same); foreach($same as $skey => $val){ $result = array_merge($result, array_fill(0, $val, $skey)); } var_dump($same); } } } var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [2]=> int(1) [3]=> int(1) } array(9) { [0]=> int(9) [1]=> int(9) [2]=> int(9) [3]=> int(9) [4]=> int(1) [5]=> int(1) [6]=> int(1) [7]=> int(2) [8]=> int(3) }

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:
146.84 ms | 406 KiB | 5 Q