Created
March 10, 2018 15:13
-
-
Save novia713/f0870052565f8f9b216bbf5d505af1c3 to your computer and use it in GitHub Desktop.
funcPHP::TailHead
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 | |
$head = function($a) { | |
return array_shift($a); | |
}; | |
$tail = function($a) { | |
$first = array_shift($a); | |
return $a; | |
}; | |
$loop = function($a) use (&$loop, $head, $tail){ | |
if (!empty($head($a))){ | |
print($head($a)); | |
$loop($tail($a)); | |
} | |
}; | |
$loop([1,2,3,4,5]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment