3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ 0 => 'AXA', 1 => 'VHV', 2 => 'TEST', ]; $doctypes = [ 12 => 'AXA', 156 => 'VHV', 8 => 'TEST', ]; $tops = array_map( function (string $name) use ($doctypes) { return in_array($name, $doctypes) ? $name : null; }, $a ); var_dump($tops); exit;
Output for 7.3.0rc3
array(3) { [0]=> string(3) "AXA" [1]=> string(3) "VHV" [2]=> string(4) "TEST" }