字母顺序颠倒而单词顺序不变的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 Smarty date_format [格式化时间日期]

Example 5-8. date_format[日期格式] index.php: 复制代码 代码如下: $smarty = new Smarty; $smarty->assign...

php google或baidu分页代码

复制代码 代码如下:<?php /** 作者:潇湘博客 时间: 2009-11-26 php技术群: 37304662 使用方法: include_once'Pager.class...

攻克CakePHP系列二 表单数据显示

攻克CakePHP系列二 表单数据显示

首先建立数据库cake_ext,并执行如下sql文: CREATE TABLE `companies` (   `id` ...

使用php shell命令合并图片的代码

复制代码 代码如下: #!/usr/local/bin/php -q author:freemouse <?php // 下面是说明. print ("本程序用于合并2张 640x...

使用php来实现网络服务

作者:samisa 以下文中的翻译名称对照表 : payload: 交谈内容 object: 实例 function: 函数 使用 php来实现网络服务 使用框架: WSO2 WSF/P...