Jump to content

For loops are a pain


Drezard

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.