<?php
$array1 = [
1 => "tenants",
2 => "modules",
];
$array2 = [
"child" => [
"prefix" => "tenants",
"slug" => "tenants",
"child" => [
[
"prefix" => "modules/{id}",
"slug" => "modules"
],
[
"prefix" => "fetch/{id}",
"slug" => "fetch"
],
],
],
];
$res = [];
$result =[];
foreach ($array1 as $asd) {
array_walk_recursive($array2['child'],
function ($item, $key) use (&$result, &$res, &$asd) {
if ($key == "slug") {
if ($item == $asd) {
$res[] = $item;
}
}
if ($key == 'prefix') {
$result[] = $item;
}
});
}
print_r($result);
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- Array
(
[0] => tenants
[1] => modules/{id}
[2] => fetch/{id}
[3] => tenants
[4] => modules/{id}
[5] => fetch/{id}
)
preferences:
137.62 ms | 408 KiB | 5 Q