Stack Exchange
How to search for data from one array in another arrays and display it as another fields in CakePHP
I have my array
Array
(
    [0] => Dusche
    [1] => Mobliert
)

And I have second array which is composed and looks like this:
[0] => Array
    (
        [id] => 1002
        [attribute_id] => 65
        [value_id] => 26815
        [name] => Garten/-mitbenutzung
        [order] => 0
    )

[1] => Array
    (
        [id] => 1003
        [attribute_id] => 65
        [value_id] => 26811
        [name] => Etagenheizung
        [order] => 1
    )

[2] => Array
    (
        [id] => 1004
        [attribute_id] => 65
        [value_id] => 26829
        [name] => Balkon/Terrasse
        [order] => 2

How can I search this second array with values from the first array and retrieve attribute_id from elements which have the same names?

PHP way:
filteredArray = array();
foreach ($secondArray as $type) {
    if (in_array($type['name'], $firstArray)) {
        $filteredArray[] = $type['attribute_id'];
    }
}

Cake Set way, something along the lines of:
$filteredArray = array();
foreach ($firstArray as $keyword) {
    $filteredArray = array_merge($filteredArray, Set::extract("/.[name=$keyword]/attribute_id", $secondArray));
}

