Re: explode () question
| From: | Malcolm | Date: | Mon, 10 Nov 2003 18:42:48 +0000 |
| Subject: | Re: explode () question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169066@lists.php.net to get a copy of this message | ||
Thanks to everyone who replied. I have taken the short route and changed the source data.
I should have thought of that first I suppose.
Now I have a few existing records to edit but from now on I'll be automagic.
On Mon, 10 Nov 2003 19:00:52 +0100, Wouter Van Vliet <wouter@springt.nl> wrote:
(after more and more discussion, this will be my first "non-top" post)-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/$rint1= rtrim($rintydata); echo $rint1; $rint2= explode(":", $rint1); The data starts like this (from and email, there are many) ; Time: November 9th 2003, 10:37AM - PST IP Address: xx.xx.xxx.xxx Browser Type: Opera/7.20 (Windows NT 5.1; U) [en] Referer: The problem is that when I do this ; while( $res=each($rint2) ) { echo "<br>$res[1]<br>"; }; the colon in Time messes things up. here is the result ; Time November 8th 2003, 07 15PM - PST IP Address xx.xx.xx.xxx Browser Type Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer when what I really want is ; Time - November 8th 2003, 07:15PM - PST IP - Address xx.xx.xx.xxx Browser Type - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer - I'd try something like:1 <?php 2 $String = 'From: Wouter van Vliet <wouter@springt.nl>'; 3 preg_match('/^\s*([^:]*)\s*:\s*(.*)$/', $String, $Matches); 4 5 print_r($Matches); 6 7 ?>==> OUTPUT: Array ([0] => From: Wouter van Vliet <wouter@springt.nl> [1] => From [2] => Wouter van Vliet <wouter@springt.nl>) From here you'd be able to manipulate the things you want in any format you'd want it to have. Or use preg_match_all() if you have all mail headers in one variable.