well in my case i had an array like this
1 => 'red'
0 => 'green'
but i needed to go through it in the order of 0 first and then 1, foreach does it the other way around.
the javascript style for loop surprised me, was always very used to my foreach 🙂
In the end i decided to just use a database sort, so that my array comes out like
0 => 'green'
1 => 'red'
Suppose i could have also done a ksort on the array
my code in example one couldn't work because it was possible to have 1 and then 3, so skipping the two