Skip to content

Instantly share code, notes, and snippets.

@novia713
Created March 10, 2018 15:13
Show Gist options
  • Save novia713/f0870052565f8f9b216bbf5d505af1c3 to your computer and use it in GitHub Desktop.
Save novia713/f0870052565f8f9b216bbf5d505af1c3 to your computer and use it in GitHub Desktop.
funcPHP::TailHead
<?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