To swap the code via php would require a trip back to the server (such as via AJAX). Since you specify you've no database on the server (related to this), I'll presume you also mean no text files or anything else that's used as a data source.
With that being said, everything you need is on the client and therefore you should be using javaScript to do the work.
As for even that, you've two primary approaches, the better one to select depending upon the types of HTML elements these are:
- Swap values
- Swap Locations
One may nuance this to other levels, such as capturing and replacing 'innerHTML', but that's the sensible way to handle this.
(As an aside: I prefer php to javaScript when I do have a choice - it's just more fun).