Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 989031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:43:37+00:00 2026-05-16T05:43:37+00:00

I would like to parse a mailer to-string which could consist of the following

  • 0

I would like to parse a mailer to-string which could consist of the following examples separated with a comma (,):

First name <email@example.com>
"first name" <email@example.com>
<email@example.com>
email@example.com

I would like to make an array with an entry for each element with two sub-entries: [name] and [email].

I’ve been struggling with the regexp for (what looks like) ages. Could someone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:43:38+00:00Added an answer on May 16, 2026 at 5:43 am

    If you have the imap extension enabled, it may be as simple as:

    var_dump(imap_rfc822_parse_adrlist('First name <email@example.com>,
        "first name" <email@example.com>,
        <email@example.com>,
        email@example.com','_invalid_'));
    

    Output:

    array(4) {
      [0]=>
      object(stdClass)#1 (3) {
        ["mailbox"]=>
        string(5) "email"
        ["host"]=>
        string(11) "example.com"
        ["personal"]=>
        string(10) "First name"
      }
      [1]=>
      object(stdClass)#2 (3) {
        ["mailbox"]=>
        string(5) "email"
        ["host"]=>
        string(11) "example.com"
        ["personal"]=>
        string(10) "first name"
      }
      [2]=>
      object(stdClass)#3 (2) {
        ["mailbox"]=>
        string(5) "email"
        ["host"]=>
        string(11) "example.com"
      }
      [3]=>
      object(stdClass)#4 (2) {
        ["mailbox"]=>
        string(5) "email"
        ["host"]=>
        string(11) "example.com"
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use JSON.NET and I would like to parse the following object which I
I have a following string that I would like to parse into either a
I would like to parse following string to get the value 46.4400 INR <div
I would like to parse comma separated values from a url parameter in Ruby
I would like to parse a varialbe name into a JSON string: JSON: {
Hi Guys I would like to parse the following xml string in C# i
I would like to parse this xml file: <?xml version=1.0 encoding=utf-8?> <resources> <string-array name=descripciones>
I would like to parse the following bibtex string or maybe a whole .bib
I would like to parse the following text into formatted URLs with anchor tags:
I would like to parse the folder name and file name from passed argument.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.