Created
December 13, 2015 19:20
-
-
Save jm42/7f61fcf14819955e79f2 to your computer and use it in GitHub Desktop.
Match and call... match and call.
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 match() { | |
| func_num_args() or die('Remember the milk?'); | |
| $fnm = function() { return true; }; | |
| $fns = func_get_args(); | |
| if (is_string($match = func_get_arg(0))) { | |
| $fnm = function() use($match) { | |
| return $match === '/'; | |
| }; | |
| $fns = array_slice($fns, 1); | |
| } | |
| return function() use($fnm, $fns) { | |
| if (call_user_func($fnm)) { | |
| foreach ($fns as $fn) { | |
| call_user_func($fn); | |
| } | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment