3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $parts = [150, 270, 360]; $output = []; foreach ($parts as $a) { $output[] = array_count_values([$a]); } foreach ($parts as $a) { foreach ($parts as $b) { $output[] = array_count_values([$a, $b]); } } foreach ($parts as $a) { foreach ($parts as $b) { foreach ($parts as $c) { $output[] = array_count_values([$a, $b, $c]); } } } var_dump($output);
based on CGdkG
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0rc3
array(39) { [0]=> array(1) { [150]=> int(1) } [1]=> array(1) { [270]=> int(1) } [2]=> array(1) { [360]=> int(1) } [3]=> array(1) { [150]=> int(2) } [4]=> array(2) { [150]=> int(1) [270]=> int(1) } [5]=> array(2) { [150]=> int(1) [360]=> int(1) } [6]=> array(2) { [270]=> int(1) [150]=> int(1) } [7]=> array(1) { [270]=> int(2) } [8]=> array(2) { [270]=> int(1) [360]=> int(1) } [9]=> array(2) { [360]=> int(1) [150]=> int(1) } [10]=> array(2) { [360]=> int(1) [270]=> int(1) } [11]=> array(1) { [360]=> int(2) } [12]=> array(1) { [150]=> int(3) } [13]=> array(2) { [150]=> int(2) [270]=> int(1) } [14]=> array(2) { [150]=> int(2) [360]=> int(1) } [15]=> array(2) { [150]=> int(2) [270]=> int(1) } [16]=> array(2) { [150]=> int(1) [270]=> int(2) } [17]=> array(3) { [150]=> int(1) [270]=> int(1) [360]=> int(1) } [18]=> array(2) { [150]=> int(2) [360]=> int(1) } [19]=> array(3) { [150]=> int(1) [360]=> int(1) [270]=> int(1) } [20]=> array(2) { [150]=> int(1) [360]=> int(2) } [21]=> array(2) { [270]=> int(1) [150]=> int(2) } [22]=> array(2) { [270]=> int(2) [150]=> int(1) } [23]=> array(3) { [270]=> int(1) [150]=> int(1) [360]=> int(1) } [24]=> array(2) { [270]=> int(2) [150]=> int(1) } [25]=> array(1) { [270]=> int(3) } [26]=> array(2) { [270]=> int(2) [360]=> int(1) } [27]=> array(3) { [270]=> int(1) [360]=> int(1) [150]=> int(1) } [28]=> array(2) { [270]=> int(2) [360]=> int(1) } [29]=> array(2) { [270]=> int(1) [360]=> int(2) } [30]=> array(2) { [360]=> int(1) [150]=> int(2) } [31]=> array(3) { [360]=> int(1) [150]=> int(1) [270]=> int(1) } [32]=> array(2) { [360]=> int(2) [150]=> int(1) } [33]=> array(3) { [360]=> int(1) [270]=> int(1) [150]=> int(1) } [34]=> array(2) { [360]=> int(1) [270]=> int(2) } [35]=> array(2) { [360]=> int(2) [270]=> int(1) } [36]=> array(2) { [360]=> int(2) [150]=> int(1) } [37]=> array(2) { [360]=> int(2) [270]=> int(1) } [38]=> array(1) { [360]=> int(3) } }