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

yipeiwu_com6年前PHP代码库
php面试题说明 :

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

php面试题的答案:
复制代码 代码如下:

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

}

测试代码:
复制代码 代码如下:

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

打印结果:
ym eman si rolgnaf

相关文章

php模板中出现空行解决方法

在本地也解决了,但是上传到服务器依然有空行,搞了一个上午,都快崩溃了,最后决定自己想办法解决,经过几个小时的摸索终于有了完美解决方法了。 运用php显示缓冲区显示原理,成功去掉 在php...

PHP错误提示It is not safe to rely on the system……的解决方法

在php程序开发中有时会出现类似于这样的警告: PHP Warning: date(): It is not safe to rely on the system's timezone...

windows环境下php配置memcache的具体操作步骤

windows环境下php配置memcache的具体操作步骤

首先要安装好php和apache环境。我用的是wamp整合的套件php 5.2.8apache 2.2.1.1这些都准备好了后,就到 memcache 官网去下载 windows 下的...

PHP项目开发中最常用的自定义函数整理

<?php //alert提示 function alert($msg){ echo "<script>alert('$msg');</script>";...

php5.5使用PHPMailer-5.2发送邮件的完整步骤

前言 这几天一直被邮件发送功能搞得头大,作为一个小白,遇到坑总是难免的。今天终于把phpmailer搞定了,下面就来总结一下 PHPMailer - A full-featured em...