roundcubemail/program/lib/Roundcube/rcube_mime.php
static function decode_address_list($input, $max = null, $decode = true, $fallback = null, $addronly = false)
    {
        $a   = self::parse_address_list($input, $decode, $fallback);
        $out = array();
        $j   = 0;

        // Special chars as defined by RFC 822 need to in quoted string (or escaped).
        $special_chars = '[\(\)\<\>\\\.\[\]@,;:"]';

        if (!is_array($a)) {
            return $out;
        }

        foreach ($a as $val) {
            $j++;
            $address = trim($val['address']);

            if ($addronly) {
                $out[$j] = $address;
            }
            else {
                $name = trim($val['name']);
                if ($name && $address && $name != $address)
                    $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
                else if ($address)
                    $string = $address;
                else if ($name)
                    $string = $name;

                $out[$j] = array('name' => $name, 'mailto' => $address, 'string' => $string);
            }

            if ($max && $j==$max)
                break;
        }

        return $out;
    }
static function decode_address_list($input, $max = null, $decode = true, $fallback = null, $addronly = false)
    {
        $a   = self::parse_address_list($input, $decode, $fallback);
        $out = array();
        $j   = 0;

        // Special chars as defined by RFC 822 need to in quoted string (or escaped).
        $special_chars = '[\(\)\<\>\\\.\[\]@,;:"]';

        if (!is_array($a)) {
            return $out;
        }

        foreach ($a as $val) {
            $j++;
            $address = trim($val['address']);

            if ($addronly) {
                $out[$j] = $address;
            }
            else {
                $name = trim($val['name']);
                if ($name && $address && $name != $address)
                    $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
                else if ($address)
                    $string = $address;
                else if ($name)
                    $string = $name;

                $out[$j] = array('name' => $name, 'mailto' => $address, 'string' => $string);
            }

            if ($max && $j==$max)
                break;
        }

        return $out;
    }
static function decode_address_list ( $ input , $ max = null , $ decode = true , $ fallback = null , $ addronly = false ) { $ a = self :: parse_address_list ( $ input , $ decode , $ fallback ) ; $ out = array ( ) ; $ j = 0 ; // Special chars as defined by RFC 822 need to in quoted string (or escaped). $ special_chars = '[\(\)\<\>\\\.\[\]@,;:"]' ; if ( ! is_array ( $ a ) ) { return $ out ; } foreach ( $ a as $ val ) { $ j ++ ; $ address = trim ( $ val [ 'address' ] ) ; if ( $ addronly ) { $ out [ $ j ] = $ address ; } else { $ name = trim ( $ val [ 'name' ] ) ; if ( $ name && $ address && $ name != $ address ) $ string = sprintf ( '%s <%s>' , preg_match ( "/$special_chars/" , $ name ) ? '"' . addcslashes ( $ name , '"' ) . '"' : $ name , $ address ) ; else if ( $ address ) $ string = $ address ; else if ( $ name ) $ string = $ name ; $ out [ $ j ] = array ( 'name' => $ name , 'mailto' => $ address , 'string' => $ string ) ; } if ( $ max && $ j == $ max ) break ; } return $ out ; }
Split an address list into a structured array list

@param string  $input    Input string
@param int     $max      List only this number of addresses
@param boolean $decode   Decode address strings
@param string  $fallback Fallback charset if none specified
@param boolean $addronly Return flat array with e-mail addresses only

@return array Indexed list of addresses
Split an address list into a structured array list