Re: metar decoding

From: Date: Sun, 11 May 2003 00:12:44 +0000
Subject: Re: metar decoding
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147170@lists.php.net to get a copy of this message
Bryan Koschmann - Gkt wrote: > I just want to get simple values that I can do what I want with. > > If it helps, this is what the output looks like: > > 2003/05/09 17:53 > KSFF 091753Z 06008G18KT 10SM SCT090 SCT200 16/01 A3000 RMK AO2 SLP158 > T01560011 10156 20044 50002 > > The second line is always on one line. I know I can break it up using > explode, but then I have to get things like this; > > 091753Z I need the 09 and the 1753 separated and do not need the Z > 10SM I need just the 10 > SCT090 I need SCT and 090 separated > SCT200 I need SCT and 200 separated > > There are of course others, but that would at least get me started. > > I'm sure it's just a matter of regular expressions, but my brain is having > trouble grasping those If Regex gives you the headaches it gives me, [bleep] Regex. list($date, $weather, $junk) = explode("\n", $data); list($date, $time) = explode(" ", $date); echo "Date: $date Time: $time<BR>\n"; //I am reasonably certain some of my variable names are //inappropriate :-) list($code, $timestamp, $zone, $sm, $sct1, $sct2, $fraction, $hardware, $remark, $camping, $slipknots) = explode(" ", $weather); $day = substr($timestamp, 0, 2); $time = substr($timestamp, 2, 4); $sctpart1 = substr($sct1, 0, 3); $sctpart2 = substr($sct1, 3, 3); echo "Date: $day Time: $time SCT1 $sctpart1 $sctpart2<BR>\n"; I'll leave the rest as an exercise :-)

« previous php.general (#147170) next »