WordPress at a glance
function is not described

PHPMailer\PHPMailer

PHPMailer::parseAddresses() public WP 1.0

Parse and validate a string containing one or more RFC822-style comma-separated email addresses of the form "display name <address>" into an array of name/address pairs. Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. Note that quotes in the name part are removed.

{} It's a method of the class: PHPMailer{}

No Hooks.

Return

Array.

Usage

$result = PHPMailer::parseAddresses( $addrstr, $useimap );
$addrstr(string) (required)
The address list string
$useimap(true|false)
Whether to use the IMAP extension to parse the list

Notes

Code of PHPMailer::parseAddresses() WP 5.7.2

<?php
public static function parseAddresses($addrstr, $useimap = true)
{
    $addresses = [];
    if ($useimap && function_exists('imap_rfc822_parse_adrlist')) {
        //Use this built-in parser if it's available
        $list = imap_rfc822_parse_adrlist($addrstr, '');
        foreach ($list as $address) {
            if (
                ('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress(
                    $address->mailbox . '@' . $address->host
                )
            ) {
                //Decode the name part if it's present and encoded
                if (
                    property_exists($address, 'personal') &&
                    extension_loaded('mbstring') &&
                    preg_match('/^=\?.*\?=$/', $address->personal)
                ) {
                    $address->personal = mb_decode_mimeheader($address->personal);
                }

                $addresses[] = [
                    'name' => (property_exists($address, 'personal') ? $address->personal : ''),
                    'address' => $address->mailbox . '@' . $address->host,
                ];
            }
        }
    } else {
        //Use this simpler parser
        $list = explode(',', $addrstr);
        foreach ($list as $address) {
            $address = trim($address);
            //Is there a separate name part?
            if (strpos($address, '<') === false) {
                //No separate name, just use the whole thing
                if (static::validateAddress($address)) {
                    $addresses[] = [
                        'name' => '',
                        'address' => $address,
                    ];
                }
            } else {
                list($name, $email) = explode('<', $address);
                $email = trim(str_replace('>', '', $email));
                $name = trim($name);
                if (static::validateAddress($email)) {
                    //If this name is encoded, decode it
                    if (preg_match('/^=\?.*\?=$/', $name)) {
                        $name = mb_decode_mimeheader($name);
                    }
                    $addresses[] = [
                        //Remove any surrounding quotes and spaces from the name
                        'name' => trim($name, '\'" '),
                        'address' => $email,
                    ];
                }
            }
        }
    }

    return $addresses;
}