Home > Backend Development > PHP Tutorial > strrev()反转中文字符串

strrev()反转中文字符串

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:22:56
Original
1497 people have browsed it

如题,怎么处理中文字符串

回复内容:

如题,怎么处理中文字符串

php manual的strrev下面评论区有个函数
算是正则表达式的另类用法

<code>function utf8_strrev($str){
    preg_match_all('/./us', $str, $ar);
    return join('',array_reverse($ar[0]));
}</code>
Copy after login

把多字节字符串转化成UTF-32字符串,然后一个for循环自己反转,然后再转化成多字节字符串

Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template