& Quot; The Bible & quot; The recursion problem is confusing for 555 of the day. This post was last edited by iamsai from 2013-09-2421: 00: 08. & lt ;? Php $ strhello; reverse_ I ($ str); function & nbsp; reverse_ I ($ str) {if (strlen ($ str "Bible") the recursion problem cannot be solved 555 a day...
This post was last edited by iamsai at 21:00:08
$str='hello';
reverse_i($str);
function reverse_i($str)
{
if(strlen($str)>0)
{
reverse_i(substr($str,1));
}
echo substr($str,0,1);
return;
}
?>
Please refer to my questions:
The output result of this program is the inverted olleh output.
After reverse_ I (substr ($ str, 1) in the loop body; hello ello llo lo o
Echo substr ($ str, 0, 1); output o.
What value does the return statement return? Is it returned to the fourth row? What is the subsequent execution order? Who can help me analyze? Thank you!
Share To: 0 ){?... 'Data-pics = ''>
------ Solution --------------------
If (strlen ($ str)> 0)
?? {???
???? Reverse_ I (substr ($ str, 1); // This is a recursive call.
<--- Return here
??}
?? Echo? Substr ($ str, 0, 1 );
?? Return;