3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ 146, 173 ]; $array2 = [ 'localhost' => [ '0' => ['host_id' => 146], ], '192.168.0.43' => [ '1' => [ 'host_id' => 160 ] , ], '192.168.0.38' => [ '2' => [ 'host_id' => 173 ] ] ]; $filtered_hosts = array_filter($array2, function ($x) use ($array1) { return in_array(reset($x)['host_id'], $array1); }); print_r($filtered_hosts);

preferences:
58.18 ms | 402 KiB | 5 Q