Home >Backend Development >PHP Tutorial >php截取中文字符串取后四位

php截取中文字符串取后四位

WBOY
WBOYOriginal
2016-06-23 14:12:13992browse

$str = "需要截取的字符串";

只留下“的字符串”!!!
  
取该字符串的后四位 怎么取


回复讨论(解决方案)

$str = "需要截取的字符串";iconv_set_encoding("internal_encoding", "gbk");echo iconv_substr($str, -4);
如果是 utf-8 的就
iconv_set_encoding("internal_encoding", "utf-8");

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn