Re: looping problem?

From: Date: Tue, 30 Dec 2003 16:15:46 +0000
Subject: Re: looping problem?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-173491@lists.php.net to get a copy of this message
>Problem with looping over a CSV file (3 results for each line)? > >Here is the script... ><?php >$row = 1; >$file = "fa.csv"; >$id = fopen("$file","r"); > while($data = fgetcsv($id,100,",")) { > $num = count($data); > $row++; > for($c = 0; $c < $num; $c++) { > echo "host $data[0] {<br />\nhardware ethernet $data[1];<br >/>\nfixed-address $data[2];<br />\n}<br />\n"; } > } >fclose($id); >?> Remove the for-loop on the 8th line. --------------------------------------------------------------------- michal migurski- contact info and pgp key: sf/ca http://mike.teczno.com/contact.html

« previous php.general (#173491) next »