字母顺序颠倒而单词顺序不变的php代码_PHP

WBOY
Release: 2016-06-01 12:18:06
Original
854 people have browsed it

php面试题说明 :

例如:my name is fanglor =》 ym eman si orlgnaf

php面试题的答案:
复制代码 代码如下:
function restr ($str)
{
$str1 = explode (' ',$str);
$str2 = '';
$temp = '';
for ($i=0;$i{
$str2 .= $temp.strrev ($str1[$i]);
$temp = ' ';
}
return $str2;

}

测试代码:
复制代码 代码如下:
$str = "my name is fanglor ";
echo restr ($str);

打印结果:
ym eman si rolgnaf

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!