Created
December 28, 2014 22:20
-
-
Save celestocalculus/ead1a186422889e9325c to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
function reverse_array($arr){ | |
if(count($arr) > 1){ | |
$sub = reverse_array(array_slice($arr, 1)); | |
$sub[] = $arr[0]; | |
return $sub; | |
} else { | |
return $arr; | |
} | |
} | |
print_r(reverse_array([0, 1, 2, 3, 4])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment