php string reverse order

巴扎黑
Release: 2016-11-21 14:34:12
Original
4356 people have browsed it

Recently, I am writing an FTP search engine for the school network. Due to word segmentation of Chinese strings, I used a combination of forward and reverse methods, and the Chinese strings need to be reversed. I searched online and found that they were all similar and required looping, which I didn’t like very much.
So I read the manual and found that several functions can be used:
str_split() function splits strings into arrays.
array_reverse() accepts an array array as input and returns a new array with the cells in reverse order
implode() function combines the array elements into a string.
The following is the test program:
$str="There are only two basic elements in the world";
echo $str . "
";
$str=implode(array_reverse(str_split($str ,2)));
echo $str;
?>
The output result is:
There are only two basic elements in the world
The two basic kinds of elements exist only in the world

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!