What the shorcut code for check single array compare to multidimensional array?

Is there shorcut code from bottom code? the code is work. i think theres a better version of this code. i need to improve cause situation like this mostly in my code. So i creates same many boiler plate.

// Array data from post

$post_value = ['action', 'drama', 'comedy'];

// Data from genres table

$genres_table = [
    ["id" => 3, "genre" => "action"],
    ["id" => 2, "genre" => "drama"]

// Extract all table genre and save into container 

$container = []; // ['Action', 'Drama']

foreach($genres_table as $genres_tb)
    array_push($container, $genres_tb['genre']);    

// Check request value is exist inside container

foreach( $post_value as $post_vl)
    if(!in_array($post_vl, $container))
        echo "Insert {$post_vl} into database";


You could use a mixture of array_diff and array_column to get the missing genres from the $post_value array as:

$missingGenres = array_diff(
    array_column($genres_table, 'genre')
// For 0 based indexing
// $missingGenres = array_values($missingGenres)
echo '<pre>', print_r($missingGenres, true), '</pre>';

In case uniqueness of the posted values is not ensured you could use array_unique to get the unique values only.


    [2] => comedy