You are here: Re: How to grab a piece of text with help of a php-script « PHP Programming Language « IT news, forums, messages
Re: How to grab a piece of text with help of a php-script

Posted by Rik on 12/18/06 22:52

Peertje wrote:
> Hi group, I would like to show the latest aurora data on my site.
> I know this is possible with help of a php-script, but I'm a nitwit
> with php-scripting.
> That's why I'm asking for help here.
>
> The following url is being updated once every minute.
> http://sec.noaa.gov/ftpdir/lists/ace/ace_mag_1m.txt
> and contains data for the past 2 hours.
>
> I would like to show the most recent Bx, By, Bz en Bt values (see
> line 21)
> as following:.
> Bx=x.x By=x.x Bz=x.x Bt=x.x (where x.x is the most recent value)
>
> Does anyone know how I can do this with a small script?
> Help is highly appreciated !!

Dirty, but hardly quick:

<?php
$info =
file_get_contents('http://sec.noaa.gov/ftpdir/lists/ace/ace_mag_1m.txt');
preg_match('/
(?P<Bx>-?[0-9\.]+)\s*
(?P<By>-?[0-9\.]+)\s*
(?P<Bz>-?[0-9\.]+)\s*
(?P<Bt>-?[0-9\.]+)\s*
(?P<Lat>-?[0-9\.]+)\s*
(?P<Long>-?[0-9\.]+)\s*
$/sx',$info,$match);
var_dump($match);
?>

File_get_contents is rather slow, you might want to check out
http://www.php.net/manual/en/function.fseek.php to get comments on how to
get the last line quicker.

> -------------------------------------------------------------------------
-------
> Mijn Postvak In wordt beschermd door SPAMfighter
> 14181 spam-mails zijn er tot op heden geblokkeerd.
> Download de gratis SPAMfighter vandaag nog!

This is unwanted spam. Either teach SPAMfighter not to use it, or use a sig
seperator (--(space)(newline)) before it, so it will be in your signature
instead of your 'real' post.
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация