There's no way to do the last two, so that leaves the first. You need to keep track of it. (If you're using some library or framework, it may track it for you.)
It's a bad design to output all over the place. Your problem is the consequence of using that design.
Update: Fleshed out my reply.
In reply to Re: Don't reprint header
by ikegami
in thread Don't reprint header
by erpence
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |