Created
June 6, 2019 06:23
-
-
Save anushshukla/ba066bdf3e6bc020fdf1ccd9d7f747ff to your computer and use it in GitHub Desktop.
Reverse String using recursive function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function reverseString($string, &$reverseStr = '') { | |
| $length = strlen($string); | |
| $len = strlen($reverseStr); | |
| $charAt = $length-$len-1; | |
| $reverseStr .= $string[$charAt]; | |
| if($charAt) { | |
| reverse($string, $reverseStr); | |
| } | |
| return $reverseStr; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment