<?php
$array1 = [
1 => "tenants",
2 => "modules",
];
$array2 = [
"prefix" => "tenants",
"slug" => "tenants",
"child" => [
[
"prefix" => "modules/{id}",
"slug" => "modules"
],
[
"prefix" => "fetch/{id}",
"slug" => "fetch"
],
],
];
function getFromChild($item, $asd) {
if (!is_array($item)) return [];
$res = [];
if ($item["slug"] == $asd)
$res[] = $item['prefix'];
if (isset($item['child']))
foreach($item['child'] as $child)
$res = array_merge($res, getFromChild($child, $asd));
return $res;
}
$res = [];
foreach ($array1 as $asd) {
$res = array_merge($res, getFromChild($array2, $asd));
}
print_r($res);
- 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}
)
preferences:
100.45 ms | 407 KiB | 5 Q