Quick PHP port of JS parse_reqs, still needs commenting