note 23434 deleted from ref.strings by aidan
| From: | aidan@php.net | Date: | Tue, 28 Sep 2004 12:12:23 +0000 |
| Subject: | note 23434 deleted from ref.strings by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77497@lists.php.net to get a copy of this message | ||
Note Submitter: bog2k<AT>softhome<DOT>net
----
How about reversing the HTML Chars (é => é). Here is a function that is able to
reverse any of HTML entitities regardles if the entity has the ";" termination. That means
it can detect and replace "télé" => "télé", and also
"télé" => "télé".
function ReverseHtmlChars ($str, $trans_table = HTML_ENTITIES) {
$trans = get_html_translation_table ($trans_table);
$trans2 = preg_replace ("';$'", "", $trans);
$trans = array_flip ($trans);
$trans2 = array_flip ($trans2);
return strtr (strtr ($str, $trans), $trans2);
}
Also you can provide a second argument if you only want to replace the HTML specialchars.
I've read a note of the Editor in which he said that this is kinda pointless because normally
you don't need to reverse HTML chars ... well, thats partially true.
In my case I really needes something like this because this way I can strip a html file of tags,
reverse all HTML entities and obtain a very *human readable* text file !!! ... so its not so
pointless.
P.S. you can also think of a similar function that has as second argument the translation table
rather than 0/1 so you can have your own set of translations (very very useful for text
translations)
Cheers,
BoG
http://bog.ath.cx