<?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; }
You have javascript disabled. You will not be able to edit any code.