Well, now you have a working copy and you know what your "ideal" answer would be, just a case of dissecting and remaking in PHP bit by bit...
If you know how to make the bets workin your head, then working out the maths is easier (not a betting person so can't help you there!) but bit by bit is the way to go... Just post specific problems and people will help.