I think this deserves to be a ... <tip type="general programming" author="R.Livsey"> Typing = instead of == can cause all sorts of errors. Instead of typing : if ($i==0){...} Try using the format : if (0==$i){...} Now if you make the mistake of typing = instead of == you will get an error as 0 cannot be assigned a value! </tip>