Parse a string containing name and email
am 07.03.2010 03:34:22 von Don Proshetsky
Hi,
I am pulling email values out of a database and the format is as follows:
John Smith
I need to parse the string into two variables as such
$name = John Smith
$email = john.smith@somedomain.com
What would be the easiest way to do this?
Thanks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Parse a string containing name and email
am 07.03.2010 05:23:11 von Manuel Lemos
Hello,
on 03/06/2010 11:34 PM Don said the following:
> Hi,
>
> I am pulling email values out of a database and the format is as follows:
>
> John Smith
>
> I need to parse the string into two variables as such
>
> $name = John Smith
> $email = john.smith@somedomain.com
>
> What would be the easiest way to do this?
You may want to take a look at the MIME parser package. It comes with a
separate class name RFC 822 addresses that can be used exactly to parse
e-mail addresses in any valid format that may appear in message headers:
http://www.phpclasses.org/mimeparser
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Parse a string containing name and email
am 07.03.2010 07:31:07 von Kevin Kinsey
Don wrote:
> Hi,
>
> I am pulling email values out of a database and the format is as follows:
>
> John Smith
>
> I need to parse the string into two variables as such
>
> $name = John Smith
> $email = john.smith@somedomain.com
>
> What would be the easiest way to do this?
>
> Thanks.
>
[36] Sun 07.Mar.2010 0:27:35
[kadmin@archangel][~/scripts] cat split
$data="John Smith";
list($name,$email)=explode("<",str_replace(">","",$data));
echo "$name's email address is $email";
?>
[37] Sun 07.Mar.2010 0:27:40
[kadmin@archangel][~/scripts] php split
John Smith's email address is js@foo.com
Throw in a foreach() and some data writes or w/e, and you're done.
Kevin Kinsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php