If you check his comment he doesn't want it reversed, does he?
may be in the same topic i can ask another question - how to assemble the resulting array 1 01 00 02 with dots - like 220.127.116.11 ?
Here you go. The 0 case is empty
I would do it this way. (wait for Christian to get much simple logic)
You can change the delimeter in whatever way you want.