note 62370 modified in function.mb-ereg-replace by thiago
| From: | thiago@php.net | Date: | Tue, 06 Oct 2009 14:13:53 +0000 |
| Subject: | note 62370 modified in function.mb-ereg-replace by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161401@lists.php.net to get a copy of this message | ||
Are you looking for htmlentities() for multibyte strings? This might help you - it just replace
<, >, ", '
<?php
/**
* Multibyte equivalent for htmlentities() [lite version :)]
*
* @param string $str
* @param string $encoding
* @return string
**/
function mb_htmlentities($str, $encoding = 'utf-8') {
mb_regex_encoding($encoding);
$pattern = array('<', '>', '"', '\'');
$replacement = array('<', '>', '"',
''');
for ($i=0; $i<sizeof($pattern); $i++) {
$str = mb_ereg_replace($pattern[$i], $replacement[$i], $str);
}
return $str;
}
?>
--was--
Are you looking for htmlentities() for multibyte strings? This might help you - it just replace
<, >, ", '
/**
* Multibyte equivalent for htmlentities() [lite version :)]
*
* @param string $str
* @param string $encoding
* @return string
**/
function mb_htmlentities($str, $encoding = 'utf-8') {
mb_regex_encoding($encoding);
$pattern = array('<', '>', '"', '\'');
$replacement = array('<', '>', '"',
''');
for ($i=0; $i<sizeof($pattern); $i++) {
$str = mb_ereg_replace($pattern[$i], $replacement[$i], $str);
}
return $str;
}
http://php.net/manual/en/function.mb-ereg-replace.php