here is a significant gotcha!
sizeof($a) gives the size of $a when $a is an array.
but call it on a string and it will return 1. it won't treat a string like a char array, as the c language does. to get the size of a string, use strlen. also, there is no end of string character counted by strlen.