I want to get the scripts to search the $open_email_msg which different e-mails will have different info but the same format as below.
I haven\'t really used regex much
Try using the PREG_OFFSET_CAPTURE
flag for preg_match. Something like this:
preg_match('/Title: .*/', $open_email_msg, $matches, PREG_OFFSET_CAPTURE);
echo $matches[0][1];
This should give you the initial position of the string.
Note that the regex I'm using could be wrong and not take into account line endings and stuff, but that's another subject. :)
EDIT. A better solution for what you want (if I understand it correctly) would be something like this:
$title = preg_match('/Title: (.*)/', $open_email_msg, $matches) ? $matches[1] : '';
You'd then get the title into the $title
variable, and an empty string if no title was found.