File() will read the file into an array, each element of the array will
be a line from the file. Explode() will then split that line by the
delimiter you choose...

So something like this:

$file = file("filename.txt");
foreach($file as $line)
  $part = explode(',',$line);
  //now you have an array, $part[], 
  //that holds each element of the 
  //current line, do what you will

---John Holmes...

> -----Original Message-----
> From: Chris Crane [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 17, 2002 1:17 PM
> Subject: [PHP] Someone Help please
> I am getting data froma website for stock information. If I type in
> brower the URL I get a text file display list this;
> Date,Open,High,Low,Close,Volume
> 16-Jul-02,7.92,8.10,7.68,7.82,605500
> 15-Jul-02,7.98,8.02,7.59,8.02,577200
> 12-Jul-02,7.80,8.00,7.57,7.95,411100
> 11-Jul-02,7.82,7.94,7.34,7.80,802400
> Now I want to break each line and then seperate each line by the
> The
> amount of linesin the file is never known so I assume I have to use
> something like a foreach or while statement,but I am not sure the best
> to do it. This is what I have so far.
>  $Symbol = "IKN"; $LookupUrl =
> "$Symbol&format=.txt";;
$Results =
> implode('', file("$LookupUrl"));
>  $Data = array(); split("\n", $Results) = array_push($Data, $line)
> The end result I am trying to get is each line to be an element in an
> array.
> Later I will go back and stepthrough each element of the array and
> split that by the commas and have it output into an HTML table.At
> this
> is the best way I can think to deal with it. I suppose a better way to
> this would be to make this an associative array and have the data of
> line be associated with the date then I could producea variable
> like $StockData[16-Jul-02][value], but I don't know how to do any of
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to