Hi,
just look at the c code you provided:
- the first line will jump to the else and to the else and therefore set $prev with the current line
- the next line (the "{") will jump into the first if and then process $prev (which was "filled" one loop-run before)
- and so on - you will get the point of it ;-)
- print() statements within your code help a lot to learn what is going on...
Regards,
svenXY