Merge pull request #601 from fermionic/20130204-100-percent-CPU-usage-on-xmlify
move mb_strlen call out of for loop definition
This commit is contained in:
commit
a0e18a0ff8
|
@ -173,10 +173,11 @@ function autoname($len) {
|
|||
|
||||
if(! function_exists('xmlify')) {
|
||||
function xmlify($str) {
|
||||
$buffer = '';
|
||||
/* $buffer = '';
|
||||
|
||||
for($x = 0; $x < mb_strlen($str); $x ++) {
|
||||
$char = $str[$x];
|
||||
$len = mb_strlen($str);
|
||||
for($x = 0; $x < $len; $x ++) {
|
||||
$char = mb_substr($str,$x,1);
|
||||
|
||||
switch( $char ) {
|
||||
|
||||
|
@ -204,7 +205,14 @@ function xmlify($str) {
|
|||
$buffer .= $char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$buffer = mb_ereg_replace("&", "&", $str);
|
||||
$buffer = mb_ereg_replace("'", "'", $buffer);
|
||||
$buffer = mb_ereg_replace("\"", """, $buffer);
|
||||
$buffer = mb_ereg_replace("<", "<", $buffer);
|
||||
$buffer = mb_ereg_replace(">", ">", $buffer);
|
||||
|
||||
$buffer = trim($buffer);
|
||||
return($buffer);
|
||||
}}
|
||||
|
@ -214,8 +222,13 @@ function xmlify($str) {
|
|||
|
||||
if(! function_exists('unxmlify')) {
|
||||
function unxmlify($s) {
|
||||
$ret = str_replace('&','&', $s);
|
||||
$ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret);
|
||||
// $ret = str_replace('&','&', $s);
|
||||
// $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret);
|
||||
$ret = mb_ereg_replace('&', '&', $s);
|
||||
$ret = mb_ereg_replace(''', "'", $ret);
|
||||
$ret = mb_ereg_replace('"', '"', $ret);
|
||||
$ret = mb_ereg_replace('<', "<", $ret);
|
||||
$ret = mb_ereg_replace('>', ">", $ret);
|
||||
return $ret;
|
||||
}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue