Posted by Michael Fesser on 11/04/07 10:44
..oO(windandwaves)
>I need to write a tricky replacement function.
>
>C = replace A with B in C
>C = replace D with E in C
>
>examples of A could be "a cat climbs a tree", examples of B could be
>"a dog climbs a alligator". Thereby, I want to make sure that parts
>that have already been replaced will not be replaced again (by the E
>replaces D statement for example). I will mark all new text (Bs and
>Es) with <span class="replacePart">... new text here ....</span>.
>
>How could I go about this? Could I use a regular expression?
You could try strtr() first, called with only two parameters. See the
manual for details.
http://www.php.net/strtr
Micha
[Back to original message]
|