rossmurphy Posted November 4, 2009 Share Posted November 4, 2009 Hi all, I have a language file with language keys that look something like this.. $lang["label.gameid"] = "Juego núm."; $lang["title.video.poker"] = "Video póker"; I use the htmlentities(); function to get them and echo them to the html page. I want to be able to use HTML in the keys though. Something like this.. $lang["title.video.poker"] = "<span class="bold">Video póker</span>"; Then i would use html_entity_decode(). But this doesn't work for the special characters. How can i go about doing this? Would i have to have my language keys like this: $lang["title.video.poker"] = "<span class="bold">Video póker</span>"; Already converted to html characters or is there another way to do this? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/180301-solved-languages-and-language-keys/ Share on other sites More sharing options...
lemmin Posted November 4, 2009 Share Posted November 4, 2009 Try htmlspecialcharacters: http://us3.php.net/manual/en/function.htmlspecialchars.php Link to comment https://forums.phpfreaks.com/topic/180301-solved-languages-and-language-keys/#findComment-951162 Share on other sites More sharing options...
rossmurphy Posted November 4, 2009 Author Share Posted November 4, 2009 Thanks for your reply, i had already tried that, sorry i didn't mention. I found a solution though. Not sure what characters ranges it will work for, but seems good so far, i will keep it updated. <?php $translation = get_html_translation_table(HTML_ENTITIES); $str = "Hallo & <span class=\"bold\">Frau</span> & Krämer"; $encoded = strtr($str, $translation ); echo htmlspecialchars_decode($encoded); ?> Link to comment https://forums.phpfreaks.com/topic/180301-solved-languages-and-language-keys/#findComment-951293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.