Monday, June 10, 2002, 5:12:50 PM, you wrote:

> Monday, June 10, 2002, 5:07:48 PM, you wrote:

>> Does anyone have or know of a function that will take an array and 
>> do array_reverse() recursively?  I have the following array/structure:

> Something like this (UNTESTED!!)...

> function recursive_array_reverse($arr)
> {
>     foreach ($arr as $key => $val)
>     {
>         if (is_array($val))
>             $arr[$key] = recursive_array_reverse($val);
>     }
>     return $arr;
> }

> Let me know if this works.

D'oh, forgot the call to array_reverse :).

function recursive_array_reverse($arr)
{
    foreach ($arr as $key => $val)
    {
        if (is_array($val))
            $arr[$key] = recursive_array_reverse($val);
    }
    return array_reverse($arr);
}

-- 
Stuart


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to