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

yipeiwu_com5年前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

相关文章

比file_get_contents稳定的curl_get_contents分享

分享一个实际在用的函数: 复制代码 代码如下: /*比file_get_contents稳定的多!$timeout为超时时间,单位是秒,默认为1s。*/ function curl_ge...

SESSION存放在数据库用法实例

本文实例讲述了SESSION存放在数据库用法。分享给大家供大家参考。具体如下: <?php /* CREATE TABLE `ws_sessions` ( `sess...

php生成gif动画的方法

首先需要确认GD库是否正常,如果是合成图片,请确保把分解的图片放在frames的文件夹里面。 GIFEncoder.class.php 类 <? Class GI...

php 遍历数据表数据并列表横向排列的代码

复制代码 代码如下:<?php $a = array (1,2,3,4,5,6,7,8,9,10,11); $i = 0; ?> <table border=1>...

PHP swoole和redis异步任务实现方法分析

PHP swoole和redis异步任务实现方法分析

本文实例讲述了PHP swoole和redis异步任务实现方法。分享给大家供大家参考,具体如下: redis异步任务 interface.php <?php for($...