Skip to content

Instantly share code, notes, and snippets.

@celestocalculus
Created December 28, 2014 22:20
Show Gist options
  • Save celestocalculus/ead1a186422889e9325c to your computer and use it in GitHub Desktop.
Save celestocalculus/ead1a186422889e9325c to your computer and use it in GitHub Desktop.
<?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