function getNestedArray(array $data) : array
{
$result = [];
foreach ($data as $key => $value) {
$path = explode('.', $key);
$current = &$result;
foreach ($path as $part) {
if (!isset($current[$part])) {
$current[$part] = [];
}
$current = &$current[$part];
}
}
return $result;
}
function addDescriptionToProducts($array, $arrayText) {
foreach ($array as &$arr) {
foreach ($arr as &$product) {
foreach ($arrayText as $text) {
if (isset($text[$product['sku']])) {
$product['desc'] = $text[$product['sku']];
break;
}
}
}
}
return $array;
}