Dekthro Posted July 6, 2009 Share Posted July 6, 2009 For learning purposes, I'm trying to write a script for World of Warcraft, which will show boss progression. This is my first script and so far so good. Originally, I have it set up so that there is a piece of code for each zone (or, dungeon), and now I'm attempting to condense it using only one chunk of code. Here is what I have. <? //Defining bosses and their status #--------------------------------------------------# // 1 = Dead 0 = Alive $argent = array ( array ('Gormok', '0,'), array ('Achidmaw', '0'), array ('Dreadscale', '0'), array ('Icehowl', '0'), array ('Lord Jaraxxus', '0'), array ('Edyis Darkbane', '0'), array ('Fjola Lightbane', '0'), array ('Final Boss', '0') ); $ulduar = array( array ('Flame Leviathan', '1'), array ('Razorscale', '1'), array ('Ignus', '1'), array ('XT-002', '1'), array ('Iron Council', '1'), array ('Kologarn', '1'), array ('Auraiya', '1'), array ('Hodir', '0'), array ('Thorim', '0'), array ('Freya', '1'), array ('Mimiron', '0'), array ('General Verax', '0'), array ('Yogg-Saron', '0'), array ('Algalon', '0'), ); $eye = array( array ('Malygos', '1') ); $obsidian = array( array ('Sartharion', '1') ); $naxxramas = array( array ('Anub\'Rekhan', '1'), array ('Faerlina', '1'), array ('Maexxna', '1'), array ('Noth', '1'), array ('Heigan', '1'), array ('Loatheb', '1'), array ('Razuvious', '1'), array ('Gothik', '1'), array ('Four Horsemen', '1'), array ('Patchwerk', '1'), array ('Grobbulus', '1'), array ('Gluth', '1'), array ('Thaddius', '1'), array ('Sapphiron', '1'), array ('Kel\'Thuzad', '1') ); $vault = array( array ('Archavon', '1'), array ('Emalon', '1'), array ('Koralon', '0') ); ///////////////////////////// // End user configuration! // ///////////////////////////// $zonevar = array ('argent', 'ulduar', 'eye', 'obsidian', 'naxxramas', 'vault'); $zonename = array ( 'argent' => 'Argent Coliseum', 'ulduar' => 'Ulduar', 'eye' => 'Eye of Eternity', 'obsidian' => 'Obsidian Sanctum', 'naxxramas' => 'Naxxramas', 'vault' => 'Vault of Archavon' ); //How many zones exist $total_zones = count($zonevar); //Display it all, with one piece of code? for ($i=0; $i < $total_zones; $i++){ echo $zonename[$zonevar[$i]].'<br>'; for ($ii=0; $ii < count($$zonevar[$i]); $ii++){ $z = $zonevar[$i]; echo $$z[$ii]['0']; } echo '<br>'; } ?> But instead I'm receiving Argent Coliseum Fatal error: Cannot use string offset as an array in progressionchart.php on line 120 Line 120 being (I have snipped some unrelated code): echo $$z[$ii]['0']; End results that I'm looking to achieve should be something like.... Zone Boss 1 Boss 2 Boss 3 ... Zone 2 Boss 1 Boss 2 Boss 3 ... And so on... Link to comment https://forums.phpfreaks.com/topic/164888-arrays-in-arrays-in-loops-wow-boss-progression-script/ Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 like so? <? //Defining bosses and their status #--------------------------------------------------# // 1 = Dead 0 = Alive $argent = array ( array ('Gormok', '0,'), array ('Achidmaw', '0'), array ('Dreadscale', '0'), array ('Icehowl', '0'), array ('Lord Jaraxxus', '0'), array ('Edyis Darkbane', '0'), array ('Fjola Lightbane', '0'), array ('Final Boss', '0') ); $ulduar = array( array ('Flame Leviathan', '1'), array ('Razorscale', '1'), array ('Ignus', '1'), array ('XT-002', '1'), array ('Iron Council', '1'), array ('Kologarn', '1'), array ('Auraiya', '1'), array ('Hodir', '0'), array ('Thorim', '0'), array ('Freya', '1'), array ('Mimiron', '0'), array ('General Verax', '0'), array ('Yogg-Saron', '0'), array ('Algalon', '0'), ); $eye = array( array ('Malygos', '1') ); $obsidian = array( array ('Sartharion', '1') ); $naxxramas = array( array ('Anub\'Rekhan', '1'), array ('Faerlina', '1'), array ('Maexxna', '1'), array ('Noth', '1'), array ('Heigan', '1'), array ('Loatheb', '1'), array ('Razuvious', '1'), array ('Gothik', '1'), array ('Four Horsemen', '1'), array ('Patchwerk', '1'), array ('Grobbulus', '1'), array ('Gluth', '1'), array ('Thaddius', '1'), array ('Sapphiron', '1'), array ('Kel\'Thuzad', '1') ); $vault = array( array ('Archavon', '1'), array ('Emalon', '1'), array ('Koralon', '0') ); ///////////////////////////// // End user configuration! // ///////////////////////////// $zonevar = array ('argent', 'ulduar', 'eye', 'obsidian', 'naxxramas', 'vault'); $zonename = array ( 'argent' => 'Argent Coliseum', 'ulduar' => 'Ulduar', 'eye' => 'Eye of Eternity', 'obsidian' => 'Obsidian Sanctum', 'naxxramas' => 'Naxxramas', 'vault' => 'Vault of Archavon' ); //How many zones exist $total_zones = count($zonevar); //Display it all, with one piece of code? for ($i=0; $i < $total_zones; $i++){ echo '<b>'.$zonename[$zonevar[$i]].'</b><br>'; foreach($$zonevar[$i] as $value){ echo $value['0']; echo '<br>'; } echo '<br>'; } ?> outputs: Argent Coliseum Gormok Achidmaw Dreadscale Icehowl Lord Jaraxxus Edyis Darkbane Fjola Lightbane Final Boss Ulduar Flame Leviathan Razorscale Ignus XT-002 Iron Council Kologarn Auraiya Hodir Thorim Freya Mimiron General Verax Yogg-Saron Algalon Eye of Eternity Malygos Obsidian Sanctum Sartharion Naxxramas Anub'Rekhan Faerlina Maexxna Noth Heigan Loatheb Razuvious Gothik Four Horsemen Patchwerk Grobbulus Gluth Thaddius Sapphiron Kel'Thuzad Vault of Archavon Archavon Emalon Koralon lemme know Link to comment https://forums.phpfreaks.com/topic/164888-arrays-in-arrays-in-loops-wow-boss-progression-script/#findComment-869521 Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 <? //Defining bosses and their status #--------------------------------------------------# // 1 = Dead 0 = Alive $argent = array ( array ('Gormok', '0,'), array ('Achidmaw', '0'), array ('Dreadscale', '0'), array ('Icehowl', '0'), array ('Lord Jaraxxus', '0'), array ('Edyis Darkbane', '0'), array ('Fjola Lightbane', '0'), array ('Final Boss', '0') ); $ulduar = array( array ('Flame Leviathan', '1'), array ('Razorscale', '1'), array ('Ignus', '1'), array ('XT-002', '1'), array ('Iron Council', '1'), array ('Kologarn', '1'), array ('Auraiya', '1'), array ('Hodir', '0'), array ('Thorim', '0'), array ('Freya', '1'), array ('Mimiron', '0'), array ('General Verax', '0'), array ('Yogg-Saron', '0'), array ('Algalon', '0'), ); $eye = array( array ('Malygos', '1') ); $obsidian = array( array ('Sartharion', '1') ); $naxxramas = array( array ('Anub\'Rekhan', '1'), array ('Faerlina', '1'), array ('Maexxna', '1'), array ('Noth', '1'), array ('Heigan', '1'), array ('Loatheb', '1'), array ('Razuvious', '1'), array ('Gothik', '1'), array ('Four Horsemen', '1'), array ('Patchwerk', '1'), array ('Grobbulus', '1'), array ('Gluth', '1'), array ('Thaddius', '1'), array ('Sapphiron', '1'), array ('Kel\'Thuzad', '1') ); $vault = array( array ('Archavon', '1'), array ('Emalon', '1'), array ('Koralon', '0') ); ///////////////////////////// // End user configuration! // ///////////////////////////// $zonevar = array ('argent', 'ulduar', 'eye', 'obsidian', 'naxxramas', 'vault'); $zonename = array ( 'argent' => 'Argent Coliseum', 'ulduar' => 'Ulduar', 'eye' => 'Eye of Eternity', 'obsidian' => 'Obsidian Sanctum', 'naxxramas' => 'Naxxramas', 'vault' => 'Vault of Archavon' ); //Display it all, with one piece of code? foreach ($zonevar as $zoneVal) { echo '<b>'.$zonename[$zoneVal].'</b><br >'."\n\n"; foreach($$zoneVal as $value) { $status = ($value[1] == 1) ? '<font color="red">Dead</font>' : '<font color="green">Alive</font>'; echo $value[0] . '(' . $status . ')'; echo '<br >'."\n"; } echo '<br >'."\n\n\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/164888-arrays-in-arrays-in-loops-wow-boss-progression-script/#findComment-869527 Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 I wish i'd have gone above and beyond :'( Nice work Link to comment https://forums.phpfreaks.com/topic/164888-arrays-in-arrays-in-loops-wow-boss-progression-script/#findComment-869529 Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 lol ty P.S I Just edited your code. shhh lol Link to comment https://forums.phpfreaks.com/topic/164888-arrays-in-arrays-in-loops-wow-boss-progression-script/#findComment-869581 Share on other sites More sharing options...
Dekthro Posted July 6, 2009 Author Share Posted July 6, 2009 Thanks a lot guys. Much less complicated then what I was trying to do. Is there a better way to display the zone names and call the data from the zone arrays? This was the best way to do it, to my knowledge. Link to comment https://forums.phpfreaks.com/topic/164888-arrays-in-arrays-in-loops-wow-boss-progression-script/#findComment-869594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.