<?php
function dg_reverse($str)
{
$max_index = strlen($str)-1;
if($max_index == 0)
{
return $str;
}
else
{
$string = substr($str, 0, $max_index);
$result = $str[$max_index].dg_reverse($string);
return $result;
}
}
$str = 'abcdef';
$r_str = dg_reverse($str);
echo $r_str;
转载于:https://blog.51cto.com/hehe1987/1652444