Simplifying code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Li0rE
Forum Commoner
Posts: 41
Joined: Wed Jun 07, 2006 6:26 am

Post by Li0rE »

Code: Select all

<?php
for($i=0; $i<9; $i++)
{ 
     $num = $i+1;
     $attack[$num] = mysql_result($result, $i, "won");
}
?>
There you go, simple as that.
Only difference is instead of getting each one by $attack3, $attack4, etc. is it is $attack[3], $attack[4].

Hope this helps.

-Li0re
Post Reply