View Full Version : PHP problem for game rankings in a cms

06-28-2005, 08:18 PM
I want the rankings to go from 1.0 to 10.0 in increments of 0.1. Well, I did it before but I forget how. Then I had some things fixed and the coder switched it back to how it was, and now I can't figure out how to do it again. Here is the code:

// grab ranking names
$ranks = explode(',',setting('article_ranknames'));
// set up selects
$options[''] = '-1';
for ($i = 1; $i <= 100; $i++)
$options[$i] = $i;
$count = 1;
while (list(,$r) = each($ranks))

right now it goes from 1 to 100. I tried changing $i to .1 but that just makes it go from 0 to 99. I also tried changing $count to .1 but it seemingly does nothing. Any ideas?

06-28-2005, 08:33 PM
surely if it goes from 1 to 100 you could just divide this result by 10 to give....

06-28-2005, 08:34 PM
Yes, but what should I change?

06-28-2005, 09:21 PM
on second thoughts change this:

for ($i = 0; $i <= 10; $i=$i+0.1)

this is untested. in my post before I was suggesting that you changed $options[$i] = $i; to $options[($i/10)] = $i/10;

(both these codes are untested)