The same form comes up again and again, with small changes depending on the underlying data, and depending also on which bits of the data are currently being changed. The same bit of PHP gets executed each time, and there are lots of conditional expressions in there. He's trying to change the way a user navigates through the various instances of this form, it's rather fiddly, and I'm trying to help.
It occurs to me that he's missing a useful technique which would assist him to think about what's going on.
Me: "Did you ever study the theory of finite-state automata?"
Him: "No, but I was good at simultaneous equations."
Not really the answer I was hoping for. I'm now debating whether it's easier to teach myself PHP, or to teach him some automata theory.