How can I get this loop to echo only the last $counter value?
for($counter=0; $counter<$length; $counter++) { echo "$counter"; }
}
Think about that one again.
for($counter=$length+1; $counter>$length; $counter--) { echo "$counter"; } }
Think harder. (Hint: you've just created a loop that is guaranteed to execute exactly once.)
I suspect that the original question was simplified beyond the point of necessity. :-)