<?php
$personas = [
'Franz' => [
'interests' => ['all'],
'gender' => 'maskulin'
],
'Sissi' => [
'interests' => ['kitesurfing', 'tennis'],
'gender' => 'feminin'
],
'Egon' => [
'interests' => ['kitesurfing', 'cinema'],
'gender' => 'maskulin'
],
'Maria' => [
'interests' => ['cinema', 'soccer'],
'gender' => 'feminin'
]
];
$interests = ['all', 'kitesurfing'];
$filtered = array_filter($personas, function($v) use ($interests) {
return array_intersect($interests, $v['interests']);
});
var_export($filtered);
Выход:
array (
'Franz' =>
array (
'interests' =>
array (
0 => 'all',
),
'gender' => 'maskulin',
),
'Sissi' =>
array (
'interests' =>
array (
0 => 'kitesurfing',
1 => 'tennis',
),
'gender' => 'feminin',
),
'Egon' =>
array (
'interests' =>
array (
0 => 'kitesurfing',
1 => 'cinema',
),
'gender' => 'maskulin',
),
)