Home >Backend Development >PHP Tutorial >PHP code that reverses the order of letters but keeps the order of words_PHP tutorial

PHP code that reverses the order of letters but keeps the order of words_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:34:50838browse

Description of php interview questions:

For example: my name is fanglor => ym eman si orlgnaf

Answers to php interview questions:

Copy 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322330.htmlTechArticleInstructions for php interview questions: For example: my name is fanglor =》ym eman si orlgnaf Answers to php interview questions: Copy The code is as follows: function restr ($str) { $str1 = explode (' ',$str); $str...
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