<?php
//Recursion
// a recursive function is one that calls itself
function reverse_r($str) {
if (strlen($str)>0) {
reverse_r(substr($str, 1));
}
echo substr($str, 0, 1);
return;
}
function reverse_i($str) {
for ($i=1; $i
}
return;
}
reverse_r('Hello');
reverse_i('Hello');
?>
No comments:
Post a Comment