$connection) { $area['connections'][$areaSlug]['modules/tuxemon.slug'] = json_decode(@file_get_contents(__DIR__ . "/areas/$areaSlug.json") ?? '', true)['modules/tuxemon.slug'] ?? ''; } $area['locations'] ??= []; foreach ($area['locations'] as $locationId => $location) { if ($location['type'] == 'shop') { $economySlug = $location['modules/tuxemon.economy']; $scoop = json_decode(file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/economy/$economySlug.json"), true); array_unshift($area['locations'][$locationId]['items'], ...$scoop['items']); } } file_put_contents(__DIR__ . "/_generated/areas/$fileName.json", json_encode($area)); }