getMessage(); } $query = "SELECT Id,LevelName FROM levels WHERE Name != 'Expansion' AND Name != ''"; $levels = PDO_FetchAssoc($query); $query = "SELECT * FROM levels WHERE Name != 'Expansion' AND Name != ''"; $levelsAll = PDO_FetchAll($query); $query = "SELECT Id,Name FROM lvlwarp"; $lvlwarp = PDO_FetchAssoc($query); $query = "SELECT monstats.Id, strings.String AS Name FROM monstats LEFT JOIN strings ON monstats.NameStr = strings.Key;"; $monstats = PDO_FetchAssoc($query); //ddump($monstats); $query = "SELECT LevelName,Vis0,Vis1,Vis2,Vis3,Vis4,Vis5,Vis6,Vis7 FROM levels WHERE Name != 'Expansion' AND Name != ''"; $res = PDO_FetchAll($query); $output = []; foreach ($res as $key => $item) { $newItem = []; $newItem['LevelName'] = $item['LevelName']; // Copy the LevelName to new item foreach ($levelsAll[$key] as $levelsKey => $levelsValue) { $newItem[$levelsKey] = isset($monstats[$levelsValue]) ? $monstats[$levelsValue] : $levelsValue; } $foundLevels = []; // Store found level names to avoid duplicates foreach ($item as $subKey => $subItem) { // Check if the key starts with 'Vis', has a corresponding level, is non-empty, and is not a duplicate if (strpos($subKey, 'Vis') === 0 && isset($levels[$subItem]) && $levels[$subItem] !== '' && !in_array($levels[$subItem], $foundLevels)) { $newItem[$subKey] = $subItem; $foundLevels[] = $levels[$subItem]; // Add to found levels } } $output[] = array_filter($newItem); // Add the modified item to the output array } unset($output[0]); ?>
Id | LevelName | Name | Vis | Warp |
---|---|---|---|---|