- var_dump: documentation ( source)
- array_intersect: documentation ( source)
<?php
$assoc_array = array(
array(
'firstname' => 'John',
'lastname' => 'Doe',
'age' => 26
),
array(
'firstname' => 'Sophia',
'lastname' => 'Smith',
'age' => 30
)
);
$array = array(
'firstname' => 'John',
'lastname' => 'Doe'
);
foreach($assoc_array as $sub){
$match = array_intersect($sub, $array);
if($match) $new[] = $sub;
}
var_dump($new);