note 82678 added to function.htmlentities

From: Date: Mon, 21 Apr 2008 18:34:15 +0000
Subject: note 82678 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-138620@lists.php.net to get a copy of this message
Hi, below a method to convert UTF-8 Latin-1 characters to HTML-Entity, I'm created this to translate string with HTML element on it and i just wont to convert entities. function convertLatin1ToHtml($str) { $html_entities = array ( "&" => "&", #ampersand "á" => "á", #latin small letter a "Â" => "Â", #latin capital letter A "â" => "â", #latin small letter a "Æ" => "Æ", #latin capital letter AE "æ" => "æ", #latin small letter ae "À" => "À", #latin capital letter A "à" => "à", #latin small letter a "Å" => "Å", #latin capital letter A "Ã¥" => "å", #latin small letter a "Ã" => "Ã", #latin capital letter A "ã" => "ã", #latin small letter a "Ä" => "Ä", #latin capital letter A "ä" => "ä", #latin small letter a "Ç" => "Ç", #latin capital letter C "ç" => "ç", #latin small letter c "É" => "É", #latin capital letter E "é" => "é", #latin small letter e "Ê" => "Ê", #latin capital letter E "ê" => "ê", #latin small letter e "È" => "È", #latin capital letter E ... sorry cutting because limitation of php.net ... ... but the principle is it ;) ... "û" => "û", #latin small letter u "Ù" => "Ù", #latin capital letter U "ù" => "ù", #latin small letter u "Ü" => "Ü", #latin capital letter U "ü" => "ü", #latin small letter u "Ý" => "Ý", #latin capital letter Y "ý" => "ý", #latin small letter y "ÿ" => "ÿ", #latin small letter y "Ÿ" => "Ÿ", #latin capital letter Y ); foreach ($html_entities as $key => $value) { $str = str_replace($key, $value, $str); } return $str; } ---- Server IP: 194.153.94.10 Probable Submitter: 77.56.149.211 ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- https://master.php.net/note/edit/82678 Del: integrated -- https://master.php.net/note/delete/82678/integrated Del: useless -- https://master.php.net/note/delete/82678/useless Del: bad code -- https://master.php.net/note/delete/82678/bad+code Del: spam -- https://master.php.net/note/delete/82678/spam Del: non-english -- https://master.php.net/note/delete/82678/non-english Del: in docs -- https://master.php.net/note/delete/82678/in+docs Del: other reasons-- https://master.php.net/note/delete/82678 Reject -- https://master.php.net/note/reject/82678 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138620) next »