Home > Backend Development > PHP Tutorial > PHP code PHP code with the alphabetical order reversed and the word order unchanged

PHP code PHP code with the alphabetical order reversed and the word order unchanged

WBOY
Release: 2016-07-29 08:43:33
Original
925 people have browsed it

PHP interview question description:
For example: my name is fanglor => ym eman si orlgnaf
Answer to PHP interview question:

Copy the code The code is as follows:


function restr ($str)
{
$str1 = explode (' ',$str);
$str2 = '';
$temp = '';
for ($i=0;$i{
$str2 . = $temp.strrev ($str1[$i]);
$temp = ' ';
}
return $str2;
}


Test code:

Copy code The code is as follows:


$str = "my name is fanglor ";
echo restr ($str);


Print result:
ym eman si rolgnaf

The above introduces the php code. The php code with the alphabetical order reversed and the word order unchanged, including the content of php code. I hope it will be helpful to friends who are interested in PHP tutorials.

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