3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sortString($string) { $type_chars = str_split($string); sort($type_chars); return implode($type_chars); } function getValue($map, $input) { $key = implode(',', array_map('sortString', $input)); return $map[$key] ?? null; } function sortMap($map) { return array_reduce(array_keys($map), function ($sorted_map, $types) use ($map) { $sorted_types = preg_replace_callback('/[A-Z]{2}/', function ($matches) { return sortString($matches[0]); }, $types); $sorted_map[$sorted_types] = $map[$types]; return $sorted_map; }, []); } $map = sortMap([ 'CC,GG,AA,CC' => 'high', 'TT,GA,TT,CG' => 'medium', 'CT,AG,TT,GG' => 'low', ]); echo getValue($map, ['CC', 'GG', 'AA', 'CC']) . "\n"; // high echo getValue($map, ['TT', 'AG', 'TT', 'CG']) . "\n"; // medium echo getValue($map, ['TT', 'GA', 'TT', 'GC']) . "\n"; // medium echo getValue($map, ['CT', 'AG', 'TT', 'GG']) . "\n"; // low
Output for git.master, git.master_jit, rfc.property-hooks
high medium medium low

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