[code=php]<?php

    /**
     * This function can be used to execute multiple functions and apply the callback to the elements of the
     * given array. The default array_map implementation has support for only 1 function, but can handle
     * several arrays to which the callback has to be applied. This function has support for only a single
     * array, but is able to handle multiple functions. The function also has support for multi-dimensional
     * arrays, as it's a recursive function.
     *
     * @author Gerard Klomp <gerard.klomp@sitemasters.be>
     * @version 1.0
     * @license http://sitemasters.be/mit-license.txt MIT License
     * @param array $array The source array
     * @param string $function The name of the function to be executed
     * @return array An array containing all elements of the source array after applying the callback of each function.
     */
    function array_map_recursive($array, $function)
    {
        $arguments   = func_get_args();

        if (!is_array($arguments[0]) && is_array($arguments[1]))
        {
            $temporary    = $arguments[0];
            $arguments[0] = $arguments[1];
            $arguments[1] = $temporary;

            unset($temporary);
        }

        $returnArray = array_shift($arguments);

        foreach($returnArray as $key => $value)
        {
            if (is_array($value))
            {
                         array_unshift($arguments, $value);
                $value = call_user_func_array(__FUNCTION__, $arguments);
                         array_shift($arguments);
            }
            else
            {
                foreach ($arguments as $function)
                {
                    if (function_exists($function))
                    {
                        $value = call_user_func($function, $value);
                    }
                }
            }

            $returnArray[$key] = $value;
        }

        return $returnArray;
    }