Created
March 21, 2011 19:37
-
-
Save meglio/880059 to your computer and use it in GitHub Desktop.
Finds email / name in specific email provided by Segovia, and replaced FROM value with these values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('FILE_IN', 'in.txt'); | |
define('FILE_OUT', 'out.txt'); | |
$original = file_get_contents(FILE_IN); | |
$res = preg_match('/Your Full Name:[^a-z]*(?P<fullName>[a-z ]+)[^a-z]*Email:[^a-z]*(?P<email>[1-9a-z@ \.]+)/is', $original, $matches); | |
if (!$res) exit; | |
$fullName = trim($matches['fullName']); | |
$email = trim($matches['email']); | |
$replaced = str_replace( | |
'From: Form Processor <[email protected] (mailto:[email protected])>', | |
"From: $fullName <$email (mailto:$email)>", | |
$original); | |
file_put_contents(FILE_OUT, $replaced); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment