<?php

function apply_first_argument($callback, $arg) {
    return function()use($arg, $callback) {
        $other_args = func_get_args();
        array_unshift($other_args, $arg);
        return call_user_func_array($callback, $other_args);
    };
}

function apply_last_argument($callback, $arg) {
    return function()use($arg, $callback) {
        $other_args = func_get_args();
        array_push($other_args, $arg);
        return call_user_func_array($callback, $other_args);
    };
}

$pow2_ = apply_first_argument(pow, 2);
$pow_2 = apply_last_argument(pow, 2);
echo '2 ^ 3 = ' . $pow2_(3) . PHP_EOL;
echo '3 ^ 2 = ' . $pow_2(3) . PHP_EOL;