/** * Invoke a function on all of an array's values */ public static function invoke($array, $callable, $arguments = array()) { // If one argument given for each iteration, create an array for it if (!is_array($arguments)) { $arguments = ArraysMethods::repeat($arguments, sizeof($array)); } // If the callable has arguments, pass them if ($arguments) { return array_map($callable, $array, $arguments); } return array_map($callable, $array); }