Most ticket systems I've used have had the ticket number in the subject line rather than the body - which is easier to handle. Using a regex is probably the easiest though - just make sure to use an ? in it so it stops at the first match (something like '/(^ticket_id: ([0-9]+$))?/s') although I guess the ticket_id: will be the same throughout the email so might not matter.
Feb 12, 2016
5
Level 13
php search string in email text
Dear community,
I've finished my work on a ticket system nearly. After a ticket is created an email is sent to the user. This e-mail includes at the bottom a line saying: ticket_id:XXXXX. Now when a user answeres to this mail a new reply to his ticket should be created. How can I easily use PHP to get just the ticket_number (XXXXX). Here's a sample email:
new ticket was opened. In case of reply to this e-mail a new answer will be added to your ticket.
ticket_id: 123456
somemore text bla bla
I think using a regex would be to overloaded. Keep in mind users may answer to the same email a few times.
Please or to participate in this conversation.