PHP 字符串翻转

<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/5/4
 * Time: 16:56
 */
function getRe($str,$encoding='utf-8'){
    $result = '';
    $len = mb_strlen($str);
    for($i=$len-1; $i>=0; $i--){
        $result .= mb_substr($str,$i,1,$encoding);
    }
    return $result;
}
$string = '你好啊,世界!';
echo getRe($string);

猜你喜欢

转载自blog.csdn.net/weixin_40605986/article/details/80198019
今日推荐