I'll describe my line of thinking.
What is the pattern in the sequence 5, 4, 3, 2, 1? Quite clearly, I decrease by one each time. I already know that $i increases by one each time, because that is how we wrote our for loop. My goal and what is available with $i is fairly close, so is there any way I can use $i?
Indeed there is. Instead of saying the sequence 5, 4, 3, 2, 1 decreases by one each time, I can say that the sequence increases in its distance from 5 by one each time. That is, the sequence is equivalent to 5 - 0, 5 - 1, 5 - 2, 5 - 3, 5 - 4. Notice that this lines up perfectly with $i. Therefore, our solution can be the following:
<?php
$c = count($rank); // 5
for ($i = 0; $i < $c; $i++) {
$labels [] = array("value" =>($c - $i), "text" => $i);
}
This takes a bit of intuition to see, and if you are in a similar situation and cannot figure out the pattern, you can always introduce a new variable.
<?php
$c = count($rank); // 5
for ($decreasing = $c, $i = 0; $i < $c; $i++, --$decreasing) {
$labels [] = array("value" =>$decreasing, "text" => $i);
}