Puoi usare un substr ricorsivo o un preg_replace. Appena ho un attimo ti scrivo.

EDIT:
Come non detto Grande Satifal