- array_map: documentation ( source)
- var_dump: documentation ( source)
- in_array: documentation ( source)
<?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;