PHP recreate array if it contains certain values I have $fruits_arr:

Array
(
    [0] =&gt; Array
        (
            [id] =&gt; 213
            [fruit] =&gt; banana
        )

    [1] =&gt; Array
        (
            [id] =&gt; 438
            [fruit] =&gt; apple
        )

    [2] =&gt; Array
        (
            [id] =&gt; 154
            [fruit] =&gt; peach
        )
)


And $ids_arr:

Array ( 
  [0] =&gt; 213
  [1] =&gt; 154 
)


I want to recreate $fruits_arr to have only array items where id is equal to a value from $ids_arr. I also want to maintain the index/array order of $fruits_arr. 

I'm using the following:

$selected_fruits = array();

foreach( $fruits_arr as $fruit ) :
    if ( in_array( $fruit['id'], $ids_arr ) ) :
        $selected_fruits[] = $fruit;
    endif;
endforeach;

print_r( $selected_fruits );


It seems to work but I am wondering if there is a shorter, better way to accomplish this in the latest PHP version.
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