3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 2 => [ 3, ], 3 => [ 8, ], 4 => [ 5, ], 5 => [ 8, ], 6 => [ 3, 8, ], 7 => [ 2, 5, ], 8 => [ 3, 8, ], ]; $occurrences = []; $mapped = array_map(function (array $values) use (&$occurrences) { $index = serialize($values); if (!array_key_exists($index, $occurrences)) { $occurrences[$index] = 1; return 0; } $occurrences[$index]++; return $occurrences[$index] - 1; }, $data); var_dump($mapped);
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { [2]=> int(0) [3]=> int(0) [4]=> int(0) [5]=> int(1) [6]=> int(0) [7]=> int(0) [8]=> int(1) }

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