Drezard Posted April 7, 2007 Share Posted April 7, 2007 Okay its something to do with my FOR loop. Theres something wrong with it, when I run this script it just continously runs the loop and the computer stops responding. What is wrong with my loop. Im pretty sure it was fine... (By the way, its missing that bit of the script where it sets the $spells and the $name variables. Heres the code: Focus on the FOR loop. echo "<b> Welcome to $name </b> <br> <br>"; $explodearray = explode(' ', $spells); $arraysize = count($explodearray); echo "<table width='100%'>"; echo "<tr>"; echo "<td>Spell</td>"; echo "<td>Discipline</td>"; echo "<td>Damage</td>"; echo "<td>Cost</td>"; echo "<td>Required</td>"; echo "</tr>"; for ($i = 0; $i > $arraysize; $i + 1) { $magic = $explodearray[$i]; $file = "core/combat/magic/".$magic.".const.xml"; $xml_magic = simplexml_load_file($file); $damage = $xml_magic->damage; $mastery = $xml_magic->mastery; $cost = $xml_magic->cost; $constreq = $xml_magic->constreq; $reqnumber = $xml_magic->reqnumber; echo "<tr>"; echo "<td>$magic</td>"; echo "<td>$mastery</td>"; echo "<td>$damage</td>"; echo "<td>$cost</td>"; echo "<td>$reqnumber $constreq</td>"; echo "</tr>"; } echo "<table>"; Whats wrong with my FOR loop? - Cheers, Daniel Link to comment https://forums.phpfreaks.com/topic/45984-for-loops-are-a-pain/ Share on other sites More sharing options...
frosty1433 Posted April 7, 2007 Share Posted April 7, 2007 for ($i = 0; $i < $arraysize; $i++) ?? Link to comment https://forums.phpfreaks.com/topic/45984-for-loops-are-a-pain/#findComment-223451 Share on other sites More sharing options...
neel_basu Posted April 7, 2007 Share Posted April 7, 2007 This line is wrong for ($i = 0; $i > $arraysize; $i + 1) It should be for ($i = 0; $i < $arraysize; $i += 1) or for ($i = 0; $i > $arraysize; $i -= 1) or for ($i = 0; $i < $arraysize; $i ++) or for ($i = 0; $i > $arraysize; $i --) Link to comment https://forums.phpfreaks.com/topic/45984-for-loops-are-a-pain/#findComment-223483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.