How to grab a piece of text with help of a php-script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peertje

    How to grab a piece of text with help of a php-script

    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.

    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 !!

    Thanks in advance...

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


  • Rik

    #2
    Re: How to grab a piece of text with help of a php-script

    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.

    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_conten ts('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,$matc h);
    var_dump($match );
    ?>

    File_get_conten ts 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


    Comment

    • Allodoxaphobia

      #3
      Re: How to grab a piece of text with help of a php-script

      On Mon, 18 Dec 2006 23:30:42 +0100, 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.

      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)
      errmmm. "the most recent" appears to be line 'LAST', not "line 21".

      BTW, line 2 seems to be the timestamp of when the txt file is
      (re)written -- with line 'LAST' being some 2 minutes older. (Probably
      attributed to data gathering, processing, and dissemination
      overhead.)

      Jonesy
      --
      Marvin L Jones | jonz | W3DHJ | linux
      38.24N 104.55W | @ config.com | Jonesy | OS/2
      *** Killfiling google posts: <http//jonz.net/ng.htm>

      Comment

      • Peertje

        #4
        Re: How to grab a piece of text with help of a php-script

        Thanks for the very quick replies.
        And sorry for the "spam".

        You are right about the last line.
        Saw it after I posted the thread ;-)

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


        Comment

        • Rik

          #5
          Re: How to grab a piece of text with help of a php-script

          Peertje wrote:
          Thanks for the very quick replies.
          And sorry for the "spam".
          You're sorry, but you're not doing anything about it? Nice going.

          It can be done: AFAIK you're using Outlook Express, so:

          - get OEQuotefix, amust when using OE on newsgroups.
          - add a custom signature for your newsgroup account

          Voilá, the spam of this evil company that sais it's fighting spam is in a
          signature, perfectly ignored by all normal readers (and also OE if you
          indeed uses OEQuotefix.
          --
          Rik Wasmus


          Comment

          • bill

            #6
            Re: How to grab a piece of text with help of a php-script

            Peertje wrote:
            Thanks for the very quick replies.
            And sorry for the "spam".
            >
            You are right about the last line.
            Saw it after I posted the thread ;-)
            >
            --------------------------------------------------------------------------------
            Mijn Postvak In wordt beschermd door SPAMfighter
            14181 spam-mails zijn er tot op heden geblokkeerd.
            Download de gratis SPAMfighter vandaag nog!
            >
            >
            The sig separator should be two dashes and a space ONLY, eg:

            --
            bill

            Comment

            Working...