just a point... (sorry for dropping into this thread I'm not supposed to post in)

using the $ var makes sense in here, when it was used instead of the good old $i.
but then, in the next loop he used $count.

for simplicity's sake, I would use either one, but not both.