Reputation: 3
I need to split an email different parts:
Exemple: [email protected] ==> |PRgdg|53366|Joe|@hotmail.com| ==>
|String|5 digit|String|@hotmail.com| .
I dont know what is easiest way to do it. With regular expression with preg_match() or Split/Substr/explode.
$parts = explode('@', "[email protected]");
$name = $parts[0];
$mailserver = $parts[1];
I dont know how to split "PRgdg5336Joe" in 3 part. *Details : |Unlimited number of character| Exactly 5 Digit |Unlimited number of character | @mailserver.com|
Upvotes: 0
Views: 73
Reputation: 191749
You can use a regular expression to do this and use capturing for each part.
preg_match("/(.*)(\d{5})(.*)/", $parts[0], $matches);
Now $matches
will be an array containing the full match in $matches[0]
and the three parts you need in $matches[1]
and on.
Upvotes: 1