Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function curry($f, $arg1) {
$args = func_get_args();
array_shift($args);
return function () use ($f, $args) {
$callArgs = func_get_args();
$args = array_merge($args,$callArgs);
return call_user_func_array($f,$args);
};
}
$f = curry('\\substr','Hallo Welt');
echo $f(2,-2) . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment