- print_r: documentation ( source)
- array_filter: documentation ( source)
- in_array: documentation ( source)
<?php
$Array1 = [
146,
173
];
$Array2 = [
'localhost' => [
'host_id' => 146
],
'192.168.0.43' => [
'host_id' => 160
],
'192.168.0.38' => [
'host_id' => 173
]
];
$filtered_hosts = array_filter($Array2, function($x) use ($Array1) {
return in_array($x['host_id'], $Array1);
});
print_r($filtered_hosts);