Ok, I searched the forum and there were many helpful hints on white space in strings. I tried many of them and had no luck. But I have only been learning PHP for a week so everything is hard to me.
With the help of bad76 I have made this code:
<?php
$FileArray = file ("http://weatheroffice.ec.gc.ca/data/conditions/currcond.met");
for ($i = 0 ; $i < count($FileArray); $i++)
{
$explode = explode(" ", $FileArray[$i]);
echo "<br>line #".$i;
for ($j = 0 ; $j < count($explode); $j++)
echo $j.") ".$explode[$j];
}
?>
Which works great and prints a file such as:
line #00) #City1) 2) 3) 4) 5) Date/Time6) 7) 8) 9) 10) Temp11) 12) Dew13) 14) 15) Vsby16) 17) Wx18) 19) Rh20) 21) 22) 23) Chill24) 25) Hdx26) 27) Dir28) Spd29) Gust30) Cld31) Pres32) 33) 34) Day35) WC(index)
line #10) WAE1) 2) 3) 2003/10/014) 15:005) 6) 7) 5.78) 9) 10) 4.911) 12) 24.113) 14) 15) 016) 17) 95.018) 19) -99.020) -99.021) 22) 23) 024) 25) 26) 027) -9928) 29) 30) 31) 032) 1021.133) 134) 35) 36) 37) 38) 39) 40) 41) 1742)
line #20) WAG1) 2) 3) 2003/10/014) 15:005) 6) 18.47) -99.08) -99.09) 10) 11) 012) -99.013) 14) -99.015) -99.016) 17) 18) 019) 20) 21) 022) -9923) 24) -9925) 26) -99.027) 128) 29) 30) 31) 32) 33) 34) 35) 2536)
But you will notice in line #0 after city the script is making 5 spaces when I only need one. Same thing after the Date/Time. So I want to strip the extra spaces and replace with one. It would be best to trim any spaces at the beginning or end of the string too. I figure it is best to do this before the explode loop while everything is in one big string. But I have tried ereg_replace and str_replace and I can't get any favourable results. Please help point me in the proper direction and where in the code to include the proper commands. Thank you!
Shayne