PHP recreate array if it contains certain values
Only thing you can use besides the foreach loop, it is array_filter:

$selected_fruits = array_filter($fruits_arr, function($fruit) use($ids_arr) {
    return in_array( $fruit['id'], $ids_arr );
});


looks shorter and uses native functions