PHP recursive implode function

Recursive version of the implode() function:

if(!function_exists('implode_r'))
{
    function implode_r($glue, array $arr)
    {
        $ret = '';

        foreach($arr as $piece)
        {
            if(is_array($piece))
                $ret .= $glue . implode_r($glue, $piece);
            else
                $ret .= $glue . $piece;
        }

        return $ret;
    }
}

You need JavaScript enabled to see comments.