- array_column: documentation ( source)
- print_r: documentation ( source)
- array_filter: documentation ( source)
<?php
$array1 = array (
0 =>
array (
'description' => '5390BF675E1464F32202B',
'to_email' => 'test@test.com'
),
1 =>
array (
'description' => '5390BF675E1464F32202B',
'to_email' => 'test3@test.com'
),
2 =>
array (
'description' => '5390BF675E1464F32202B',
'to_email' => 'testagain@gmail.com'
)
);
$array2 = array (
0 =>
array (
'to_email' => 'test@test.com'
),
1 =>
array (
'to_email' => 'test3@test.com'
)
);
$exclude_ids = array_column($array2, 'to_email', 'to_email');
$output = array_filter($array1, function ($v) use ($exclude_ids) {
return !isset($exclude_ids[$v['to_email']]);
});
print_r($output);