php and remove the last character of the kanji character string

### php and remove the last character of the kanji character string

1. PHP remove the last character string :

//方法一:
$newstr = substr($str,0,strlen($str)-1); 
//方法二:
$newstr = substr($str, 0, -1) 

2. PHP remove the last of a string of characters :

//坑的地方就是这个,汉字在u8编码中是占3个字符,所以得注意
$newstr = substr($str,0,strlen($str)-3);  //这是去掉字符串中的最后一个汉字

Guess you like

Origin www.cnblogs.com/alisleepy/p/11200319.html