3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=array('FA',12.9); $b=array('FA',12.9); $c=array('FB',12.2); $d=array('FC',12.3); $e=array('FA',12.9); $h=array('FA',12.4); $f=array('FB',12.9); $items=array($a,$b,$c,$d,$e,$f,$h); // Count in two different but functionally identical ways $counts_a = []; $counts_b = []; foreach($items as $item) { // Suppress the warning for missing key @$counts_a[$item[0] . ' ' . $item[1]]++; // Actually look for the key and set to zero if not found $key = $item[0] . ' ' . $item[1]; if(!array_key_exists($key, $counts_b)){ $counts_b[$key] = 0; } $counts_b[$key]++; } foreach($counts_a as $key => $count) { echo $key . 'x' . $count, PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
FA 12.9x3 FB 12.2x1 FC 12.3x1 FB 12.9x1 FA 12.4x1

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