ParseError thrown

syntax error, unexpected 'endfor' (T_ENDFOR), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)