Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7642333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:09:47+00:00 2026-05-31T09:09:47+00:00

This code retrieves information from another site: <?php $location = $ident; get_taf($location); function get_taf($location)

  • 0

This code retrieves information from another site:

<?php


    $location = $ident;

get_taf($location);

function get_taf($location) {
$fileName = "ftp://tgftp.nws.noaa.gov/data/forecasts/taf/stations/$location.TXT";
    $taf = '';
    $fileData = @file($fileName);

    if ($fileData != false) {
        list($i, $date) = each($fileData);

        $utc = strtotime(trim($date));
        $time = date("D, jS M Y Hi",$utc);

        while (list($i, $line) = each($fileData)) {
            $taf .= ' ' . trim($line);
            }
        $taf = trim(str_replace('  ', ' ', $taf));
        }


if(!empty($taf)){
    echo "Issued: $time Z
    <br><br>
    $taf";
    } else {
    echo 'TAF not available';
    }
}

?>

What its suppose to look like:

 TAF KLBX 160541Z 1606/1706 15009KT P6SM FEW009 BKN013 OVC030 
 FM160900 15005KT P6SM SCT010 BKN035 
 FM161600 16010KT P6SM VCSH SCT012 BKN030 
 FM161900 18012KT P6SM SCT025 BKN040 
 FM170000 16005KT P6SM SCT012 BKN022

What it ends up looking like:

TAF KLBX 160541Z 1606/1706 15009KT P6SM FEW009 BKN013 OVC030 FM160900 15005KT P6SM SCT010 BKN035 FM161600 16010KT P6SM VCSH SCT012 BKN030 FM161900 18012KT P6SM SCT025 BKN040 FM170000 16005KT P6SM SCT012 BKN022

How do I maintain the spacing with the rows???

It is putting all the info on 1 line and it looks like a paragraoh instead a list.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:09:49+00:00Added an answer on May 31, 2026 at 9:09 am

    Your output contains newline bytes, but in webpages those line breaks are usually treated as regular spacing characters and not as an actual line break (the br tag is used for hard breaks instead). PHP has a function to convert line breaks to br tags called nl2br, so you could do this:

    $taf = nl2br(trim(str_replace('  ', ' ', $taf)), false);
    

    Since you’re trimming the line endings of every line you’ll also have to modify something to either preserve them (by using trim with two parameters or by using just ltrim) or re-add them manually like this:

    $taf .= ' ' . trim($line) . "\n";
    

    You could also append the <br> tags directly, that would save you the conversion. Another possibility would be to just preserve/add the line endings and wrap the output in a <pre> section, this will eliminate the need of break-tags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to display the data retrieved from DB in accounts_view.php :
I try to access information from Twitter and I followed this link: http://code.google.com/p/sociallib/wiki/SocialLibGuide I
I have a code which retrieves few information from Database. For example if you
This code attempts to dynamically switch the class of the StateContainer div from StateOne
This code snippet is from C# in Depth static bool AreReferencesEqual<T>(T first, T second)
This code: $(#permalink a).click(function(id){ var id = this.getAttribute('href'); $(#newPostContent).load(id, function() { $(#removeTrigger).click(function() { $(#removeThis).hideToggle();
Im using the following code to read to consumer_key and consumer_secret from config.php, pass
This class has information that I want to send with an intent to another
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
This code gives me an empty result. I expect it to print out the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.