/**
* Calculate the length of the string (Chinese characters are calculated as two characters)
*
* @param string $str String
*
* @return int
*/
function myStrLen($str){
$length = strlen(preg_replace('/[x00-x7F]/', '', $str));
if ($length){
return strlen($str) - $length + intval($length / 3) * 2;
}
else{
return strlen($str);
}
}
/**
* Calculate the length of the string (Chinese characters are calculated as one character)
*
* @param string $str String
*
* @return int
*/
function cnForOneBetLen($str){
$length = strlen(preg_replace('/[x00-x7F]/', '', $str));
if ($length){
return strlen($str) - $length + intval($length / 3) * 1;
}
else{
return strlen($str);
}
}