3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countUnique($a) { $acv=array_count_values($a); $n=0; foreach ($acv as $f) if ($f==1) $n++; return $n; } function countUniqueTML($a) { return array_reduce( array_count_values($a), function($c, $i) { return ($i === 1) ? $c + 1 : $c; }, 0); } function countUniqueGG($a) { $cardinal=[]; foreach($a as $v) if (isset($cardinal[$v])) $cardinal[$v] = 0; else $cardinal[$v] = 1; return array_sum($cardinal); } $a=[1,1,2,2,2,5,6]; echo countUniqueTML($a); echo "\n"; echo countUnique($a); echo "\n"; echo countUnique($a);
Output for git.master, git.master_jit, rfc.property-hooks
2 2 2

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:
57.41 ms | 401 KiB | 8 Q