Jump to content

extract and parse text


dflow

Recommended Posts

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

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,

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.