port of a school project to PHP