dflow Posted May 13, 2009 Share Posted May 13, 2009 i have this file of calendar availabilities i ould like to parse only the fields containing id and the id value i managed to get the following: <?php $row = 1; $handle = fopen("getCalendar.csv", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); ?> is there a better way to parse this? here is the file id=5:'13/05/2009','14/05/2009', id=8:'13/05/2009','14/05/2009', id=11:'18/05/2009','19/05/2009' Link to comment https://forums.phpfreaks.com/topic/157980-extract-and-parse-text/ Share on other sites More sharing options...
dflow Posted May 13, 2009 Author Share Posted May 13, 2009 bump im now testing with this code: <?php $fp = fopen('getCalendar.csv','r') or die("can't open file"); print "<table>\n"; while($csv_line = fgetcsv($fp,1024)) { print '<tr>'; for ($i = 0, $j = count($csv_line); $i < $j; $i++) { print '<td>'.$csv_line[$i].'</td>'; } print "</tr>\n"; } print '</table>\n'; fclose($fp) or die("can't close file"); ?> what would be the best to extract fields like these: id=5,id=8, Link to comment https://forums.phpfreaks.com/topic/157980-extract-and-parse-text/#findComment-833334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.