note 23434 added to ref.strings
| From: | bog2k softhome | Date: | Thu, 18 Jul 2002 13:02:46 +0000 |
| Subject: | note 23434 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33249@lists.php.net to get a copy of this message | ||
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
--
http://www.php.net/manual/en/ref.strings.php
http://master.php.net/manage/user-notes.php?action=edit+23434
http://master.php.net/manage/user-notes.php?action=delete+23434
http://master.php.net/manage/user-notes.php?action=reject+23434