pincopallo_it Posted June 12, 2008 Share Posted June 12, 2008 What I have to do is to read a file, more precisely an html file. I have to read that file couse I need to use some information are written inside. The html is attached. What I need to extract is the dates and the times you can read inside the html as I have to calculate the worked hours from there. I tried reading the file line by line : $file = fopen($newname, "r") or exit("Unable to open file!"); while (!feof($file)) { $linea = fgets($file); echo $linea; // pubblica la intranet //$pos = strpos($linea, 'font face=arial size=2'); //echo $pos; // situazione della font face } but that strpos did not work ... Who has an idea ? .... hope I was clear enough ... Thanks [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/109933-read-a-complex-file/ Share on other sites More sharing options...
jonsjava Posted June 12, 2008 Share Posted June 12, 2008 a simple solution: <?php $file = "file.html"; //change this to point to the file. $fh = fopen($file, "r"); $code = fread($fh, filesize($file)); $code_array = explode("\n", $code); foreach ($code_array as $value){ if (strstr($value, "font face=arial size=2")){ $new_array[] = $value; } } print_r($new_array); //this just shows you the output. you can remove this, and in its place, take the data and manipulate it to your hearts content (the array, that is). Link to comment https://forums.phpfreaks.com/topic/109933-read-a-complex-file/#findComment-564118 Share on other sites More sharing options...
pincopallo_it Posted June 12, 2008 Author Share Posted June 12, 2008 Great ! Thanks ! Link to comment https://forums.phpfreaks.com/topic/109933-read-a-complex-file/#findComment-564145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.