1,字符串按字節反轉可用strrev()php
2,按字反轉能夠用一下代碼數組
$str="my name is linda"; $str_arr=explode(' ',$str);//將字符串按照空格分隔成數組 $new_arr=array_reverse($str_arr);//將分隔後的數組反轉 $new_str=implode(' ',$new_arr);//將數組按空格進行組合 echo $new_str;
打印結果:spa
linda is name mycode
1,字符串按字節反轉可用strrev()php
2,按字反轉能夠用一下代碼數組
$str="my name is linda"; $str_arr=explode(' ',$str);//將字符串按照空格分隔成數組 $new_arr=array_reverse($str_arr);//將分隔後的數組反轉 $new_str=implode(' ',$new_arr);//將數組按空格進行組合 echo $new_str;
打印結果:spa
linda is name mycode