Write a function to reverse a string.
<?php function reverse_string($str1) { $n = strlen($str1); if($n == 1) { return $str1; } else { $n--; return reverse_string(substr($str1,1, $n)) . substr($str1, 0, 1); } } print_r(reverse_string('1234')."\n"); ?>
Sample Output:
4321
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer