Created
August 1, 2019 08:46
-
-
Save elchroy/3d356012cd363f0b3bb3a62d6ad9b39c to your computer and use it in GitHub Desktop.
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
<?php | |
function reverseArray($a) { | |
$len = count($a); | |
$i = 0; | |
$res = []; | |
while ($i < $len) { | |
$j = abs($i - $len) - 1; | |
$res[] = $a[$j]; | |
$i++; | |
} | |
return $res; | |
} | |
print_r(reverseArray([1, 4, 5, 2, 5, 9, 2, 4, 7, 0])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment