What does $order hold at the beginning of this code? I am guessing from the way you use it in the first example that it is an associative array (not a straight numeric array) in which case you cannot just loop through the items from 0-9 as you are trying to do, since this will not work.
You could either use a loop variable in the first example or truncate the $order array to ten items before you start the loop, not sure which will be easier without knowing what your data looks like.
HTH,
Dai