- var_dump: documentation ( source)
- array_filter: documentation ( source)
- in_array: documentation ( source)
<?php
$a = [
0 => 'AXA',
1 => 'VHV',
2 => 'TEST',
];
$doctypes = [
12 => 'AXA',
156 => 'VHV',
8 => 'TEST',
];
$tops = array_filter(
$a,
function (string $name, int $key) use ($doctypes) {
return in_array($name, $doctypes);
},
ARRAY_FILTER_USE_BOTH
);
var_dump($tops);
exit;