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
> To: [EMAIL PROTECTED]
> Subject: [PHP] Someone Help please
> 
> I am getting data froma website for stock information. If I type in
the
> 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
commas.
> 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
way
> to do it. This is what I have so far.
> 
>  $Symbol = "IKN"; $LookupUrl =
> "http://demos.inxdesign.com/download?sym=$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
then
> split that by the commas and have it output into an HTML table.At
least
> this
> is the best way I can think to deal with it. I suppose a better way to
do
> this would be to make this an associative array and have the data of
each
> line be associated with the date then I could producea variable
something
> like $StockData[16-Jul-02][value], but I don't know how to do any of
that.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to