note 29114 modified in function.str-replace by tularis
| From: | tularis@php.net | Date: | Sat, 08 Feb 2003 11:50:19 +0000 |
| Subject: | note 29114 modified in function.str-replace by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43609@lists.php.net to get a copy of this message | ||
For those that don't know French, here is a (loose) translation:
Very usefull when making pages in the utf-8 format, pages that have a different charset will not
recognise this one, so use this:
/**
* Convertit les accents en entités HTML
* @param string $strTexte : chaine à traiter
* @return string chaine traitée
* @author Raf
*/
function convertToHtml($strTexte) {
$arrSearch = Array (
'é',
'è',
'ë',
'ê',
'à',
'ä',
'â',
'ù',
'ü',
'û',
'ö',
'ô',
'ï',
'î');
$arrReplace = Array(
'é',
'è',
'ë',
'ê',
'à',
'ä',
'â',
'ù',
'ü',
'û',
'ö',
'ô',
'ï',
'î');
$strReturn = str_replace($arrSearch, $arrReplace, $strTexte);
return $strReturn;
}
--was--
Pratique quand on affiche les pages au format UTF8, ou tout autre format qui ne reconnait pas les
caractères accntués.
Compléter les deux arrays selon les besoins.
/**
* Convertit les accents en entités HTML
* @param string $strTexte : chaine à traiter
* @return string chaine traitée
* @author Raf
*/
function convertToHtml($strTexte) {
$arrSearch = Array (
'é',
'è',
'ë',
'ê',
'à',
'ä',
'â',
'ù',
'ü',
'û',
'ö',
'ô',
'ï',
'î');
$arrReplace = Array(
'é',
'è',
'ë',
'ê',
'à',
'ä',
'â',
'ù',
'ü',
'û',
'ö',
'ô',
'ï',
'î');
$strReturn = str_replace($arrSearch, $arrReplace, $strTexte);
return $strReturn;
}
http://www.php.net/manual/en/function.str-replace.php