Created
August 1, 2019 08:47
-
-
Save elchroy/18ccd0bc2c3062ccb756336adfc369e2 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 | |
$arr = [1, 2, 3, 4, 5]; | |
function rotLeft($a, $d) { | |
$res = []; | |
$count = count($a); | |
array_walk($a, function ($e, $i) use (&$a, $d, $count, &$res) { | |
$res[$i] = $a[($i+$d)%$count]; | |
}); | |
return implode(' ', $res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment