Skip to content

Instantly share code, notes, and snippets.

@anushshukla
Created June 6, 2019 06:23
Show Gist options
  • Select an option

  • Save anushshukla/ba066bdf3e6bc020fdf1ccd9d7f747ff to your computer and use it in GitHub Desktop.

Select an option

Save anushshukla/ba066bdf3e6bc020fdf1ccd9d7f747ff to your computer and use it in GitHub Desktop.
Reverse String using recursive function
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