倒装一个句子

2018-12-08  本文已影响0人  我的楼兰0909
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/19
 * Time: 9:20
 * 倒装一个句子,如:把"London bridge is falling down" 变成 "down falling is bridge London"
 * 不使用额外的存储空间
 */
 
function aa($str){
    $str = strrev($str);
    $str = explode(' ',$str);
    foreach($str as $k => $v){
        $str[$k]=strrev($v);
    }
    return implode(' ',$str);
}
echo 'London bridge is falling down',"<br/>";
echo aa('London bridge is falling down');
die;//down falling is bridge London
上一篇下一篇

猜你喜欢

热点阅读