5kyy8lu3 Posted January 19, 2009 Share Posted January 19, 2009 Hi! I was working on writing some scripts to pull weather data from noaa.gov's weather text files and I'm trying to think of a good way to go about it. One thing that would really help is if I could find a way to detect where lines breaks are in the string. Is it possible to use strpos(); to find line breaks? If I can, then I could throw each line of data into it's own variable (or array). Here's the text file I'll be reading from if it helps any: ftp://tgftp.nws.noaa.gov/data/observations/metar/decoded/KOJC.TXT I don't have to do this but it would make things easier for me. Thanks ahead of time. Link to comment https://forums.phpfreaks.com/topic/141394-solved-find-linebreaks-in-a-string/ Share on other sites More sharing options...
MadTechie Posted January 19, 2009 Share Posted January 19, 2009 file — Reads entire file into an array example <?php $lines = file('ftp://tgftp.nws.noaa.gov/data/observations/metar/decoded/KOJC.TXT'); // Loop through our array, show HTML source as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/141394-solved-find-linebreaks-in-a-string/#findComment-740160 Share on other sites More sharing options...
5kyy8lu3 Posted January 19, 2009 Author Share Posted January 19, 2009 file — Reads entire file into an array example <?php $lines = file('ftp://tgftp.nws.noaa.gov/data/observations/metar/decoded/KOJC.TXT'); // Loop through our array, show HTML source as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n"; } ?> this is excellent, i appreciate the help Link to comment https://forums.phpfreaks.com/topic/141394-solved-find-linebreaks-in-a-string/#findComment-740163 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.