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 9126983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:10:41+00:00 2026-06-17T07:10:41+00:00

I have a string that is returned via imap_headers() which has a format like

  • 0

I have a string that is returned via imap_headers() which has a format like this one:

Flags Number) Date Sender Subject (Size)

and sample returned string from an array is:

A 454)22-Jun-2004 cust.serv@amazon.co.uk Your Amazon.co.uk Order (5284 chars)
1)10-Oct-2010 Gmail Team Get Gmail on your mobile (2457 chars)
5)12-Nov-2010 =?ISO-8859-1?Q?Eric_ For Website (671669 chars)
U 6)17-Nov-2010 no-reply@hostmessage host.net account : boom (2082 chars)

I want to decode/parse this string and create an object out from this string.
e.g

Flags
Date
Sender
Subject

i find it hard parsing this using php string functions because, this string is just separated by a space. Can anybody help me on this? The sender part could also be a name, so we can just treat it as an email add or a website url.

  • 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-06-17T07:10:42+00:00Added an answer on June 17, 2026 at 7:10 am

    As I mentioned above in the comments, it’s pretty much impossible to create a regular expression that will work for you, because you don’t provide enough information. However, I will give you an example that will match your line and maybe you can go on from there:

    preg_match('_([A-Z]+) (\d+)\)(\d+-[A-Za-z]+-\d{4}) (\S+@\S+\.\S+) (.+) \((\d+) chars\)_', $header, $matches);
    var_dump($matches);
    

    Now it depends on your application if you need to extend this expression to account for other variants of the possible output. You can read up on all the details of what I did there in the official documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string that look like Array that fetched from other webservice like this
I have a String that looks like this String = Förpackning Flaska (375 ml)
I have a string that looks like this: <name>-<gender>-<age>.jpg I want to be very
I have a string being returned from my database that I want to use
So i have this C++ program that is called via JNI from my Java
I have a WCF service that can return a stream via a WebGet. This
I have few NSDate objects which contain values compliant to this format yyy-MM-dd'T'HH:mm:ss.SSS When
I have an if statement that's condition is passed to this implementation file via
I have string that displays UTF-8 encoded characters, and I want to convert it
I have a String that holds the string representation of a byte value. String

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.