Luterin
05-09-2008, 10:40 AM
I would like to replace a bunch of foreign chars to a html entity, but I can not use the htmlentities function, since the string consists of a full html page, and I don't want any tags or anything within any tag to be replaced. Just the text in between the tags.
An Example:
Input:
<a html='första_sidan.html'>Detta är en länk till en sida.<br>
<img src='färger.gif'>Och en lite färg bild...Förslag, återge...
Output:
<a html='första_sidan.html'>Detta är en länk till en sida.<br>
<img src='färger.gif'>Och en lite färg bild...Förslag, återge...
The characters involved are:
å - å
ä - ä
ö - ö
Was thinking that the best sollution would be to do it with the use of preg_replace and a regular expression, since it would save alot of code and power from writing a specific funtion to do it.
But I cant get it to work, so any help and ideas are very welcome.
Thanks in advance!
(Hope the "special" chars show up, otherwise I hope you can understand what it is that I want to achieve anyway. :) )
An Example:
Input:
<a html='första_sidan.html'>Detta är en länk till en sida.<br>
<img src='färger.gif'>Och en lite färg bild...Förslag, återge...
Output:
<a html='första_sidan.html'>Detta är en länk till en sida.<br>
<img src='färger.gif'>Och en lite färg bild...Förslag, återge...
The characters involved are:
å - å
ä - ä
ö - ö
Was thinking that the best sollution would be to do it with the use of preg_replace and a regular expression, since it would save alot of code and power from writing a specific funtion to do it.
But I cant get it to work, so any help and ideas are very welcome.
Thanks in advance!
(Hope the "special" chars show up, otherwise I hope you can understand what it is that I want to achieve anyway. :) )