Re: Help with collecting data from an e-mail
| From: | Steven Werby | Date: | Sat, 19 Aug 2000 04:59:52 +0000 |
| Subject: | Re: Help with collecting data from an e-mail | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-2178@lists.php.net to get a copy of this message | ||
Jack Lauman <jlauman@nwcascades.com> wrote:
> I want to collect (6) items from the below sample and save them in a
> MySQL table. I also need to convert the date "1999.06.18" to the MySQL
> format of 1999-06-18.
Use str_replace(). <? $date_new = str_replace(".", "-", $date_old); ?>
> Does anyone know of any sample code for doing
> something like this and if so where can I find it.
If your emails are always going to be of the same format you can easily do what
you want using regular expressions. There are 2 different kinds of regular
expressions - Perl compatible and POSIX. Both are covered in the manual
(http://www.php.net/manual/). ereg() should be all you need. I'd read the
email into a variable or array using filesystem functions and then use regular
expressions to read the items you want into an array and then insert the array
contents into a MySQL table. If you need example code you can probably find
something very close to what you need by searching the mailing list archives,
phpbuilder.com message boards or looking on any number of sites for regex
tutorials and code snippets. Webmonkey, Weberdev, and px.sklar.com might be of
help.
--
Steven Werby {steven-lists@befriend.com}
President, Befriend Internet Services LLC
http://www.befriend.com/ 804-355-WEBS