Reply to Re: Newbie Question

Your name:

Reply:


Posted by Rik Wasmus on 12/19/07 12:58

On Wed, 19 Dec 2007 06:38:42 +0100, HardySpicer <gyansorova@gmail.com> =

wrote:

> I have a text file with 6 colums of data. I need to read it and in
> colums 2 and 3 do something to the data. First of all I can read the
> file (all of it) or some of it ie one line
>
> <?php
>
>
> $myFile =3D "orbit.txt";
> $fh =3D fopen($myFile, 'r');
> $theData =3D fgets($fh);
> fclose($fh);
> echo $theData;
>
>
> ?>.
>
> and this is ok. How to get to the data in colum 2 and 3 of this thing
> called $theData?
>
> Also I need to put a loop around it for i =3D 0 to end of file (do
> something)
> as in basic.

It all depends on how your file is formatted/how these elusive 'columns'=
=

are defined.
Probably csv, then this is something you want:

<?php
$myFile =3D 'file.csv';
$fh =3D fopen($myFile);
while($row =3D fgetcsv($fh)){
echo "
value 2: {$row[1]}
value 3: {$row[2]}":
}
?>
-- =

Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация