dotnet69 Posted February 5, 2008 Share Posted February 5, 2008 I want to be able to parse text from a text file into PHP coding how do you determine what line of text it puts into the PHP code in bold is what the info i want to put into the PHP code Ex This is the information i need to put into my page </html> Posts: 12 View Profile Email Personal Message (Online) Re: Trying to Add Content to Page from a text file « Reply #15 on: February 01, 2008, 11:35:40 AM » Reply with quoteQuote These are the three tables i need to pull info from <quote> Date: 2/1/2008 Split/Skill: Start Time <b>Service Level</b> ASA Calls Offered Calls Answered AHT Aban Calls % Aban % Occ. % Avail % AUX Staffed Time Avail Time Aux Time Avg Talk Time Avg Hold Time Avg ACW Time APS Max Delay Totals <b>99</b> :03 298 298 12:14 0 .00 61 27 12 117:25:15 32:02:51 14:26:02 12:35 :42 :37 - :52 7:30 AM 0 0 0 0 0 0 0 0 46 54 :20:28 :09:19 :11:09 0 0 0 1 :00 8:00 AM 100 :03 25 25 7:45 0 .00 52 41 7 8:44:51 3:36:41 :36:26 10:30 :08 :13 17 :03 8:30 AM 100 :03 28 28 11:56 0 .00 58 33 9 13:05:28 4:16:28 1:13:17 15:15 :07 :40 26 :03 9:00 AM 100 :03 39 39 10:45 0 .00 59 36 6 18:58:33 6:45:56 1:05:03 14:41 :38 :35 38 :03 9:30 AM 100 :03 50 50 14:59 0 .00 56 30 14 23:15:43 7:00:40 3:13:15 13:48 :53 :49 47 :03 10:00 AM 97 :04 71 71 12:24 0 .00 66 15 19 25:14:31 3:49:30 4:51:16 11:37 :46 :44 50 :33 10:30 AM 100 :03 85 85 12:36 0 .00 65 23 12 27:45:41 6:24:17 3:15:36 11:26 :56 :33 </html> Quote Link to comment Share on other sites More sharing options...
laffin Posted February 5, 2008 Share Posted February 5, 2008 Look for patterns before/in/after to build a parser. if u read the whole file into memory, with file_get_contents. u can preg_match or strpos to find the first occurance from looks of it ya want the first value after totals: which if using preg_match, ya can retrieve by preg_match("/^Totals\s*(\d+)\s/",$body,$match); $match[1] shud contain the value 99 Quote Link to comment Share on other sites More sharing options...
Caesar Posted February 5, 2008 Share Posted February 5, 2008 Regex, my friend. :-) Quote Link to comment Share on other sites More sharing options...
dotnet69 Posted February 5, 2008 Author Share Posted February 5, 2008 this is not what i need, and nobody seems to get what i am trying to say. i need to find the value in a text document, and link it to a specific area in a PHP script. nothing is listed for all the other codes that you are mentioning. $AHT = substr($dataLine[7], 1) This is the what i am referring to, to pull some info from a text file, what i need to know is how to interpret this string of variables Quote Link to comment Share on other sites More sharing options...
laffin Posted February 5, 2008 Share Posted February 5, 2008 from what I see this line is headers Start Time Service Level ASA Calls Offered Calls Answered AHT Aban Calls % Aban % Occ. % Avail % AUX Staffed Time Avail Time Aux Time Avg Talk Time Avg Hold Time Avg ACW Time APS Max Delay this line looks like overviews for the day Totals 99 :03 298 298 12:14 0 .00 61 27 12 117:25:15 32:02:51 14:26:02 12:35 :42 :37 - :52 the next line looks like specific info throughout the day 8:00 AM 100 :03 25 25 7:45 0 .00 52 41 7 8:44:51 3:36:41 :36:26 10:30 :08 :13 17 :03 since yer post had bold text on 2 locations ppl are gonna think those are significant to what you are trying to extract. to give ppl an understanding of what you are trying to do, you have to be very specific. such as using bold lettering to denote the info you are trying to extract. Since Service Level shudn change, it's not dynamic. but the value below it is common sense is that, the person just output "Service Level" in their html/php code rather than extract it. and grab the dynamic variable 99 which the preg_match statement does Quote Link to comment Share on other sites More sharing options...
effigy Posted February 5, 2008 Share Posted February 5, 2008 I do not understand what you're looking for. My guess is below: <pre> <?php $data = <<<DATA This is the information i need to put into my page </html> Posts: 12 View Profile Email Personal Message (Online) Re: Trying to Add Content to Page from a text file « Reply #15 on: February 01, 2008, 11:35:40 AM » Reply with quoteQuote These are the three tables i need to pull info from <quote> Date: 2/1/2008 Split/Skill: Start Time Service Level ASA Calls Offered Calls Answered AHT Aban Calls % Aban % Occ. % Avail % AUX Staffed Time Avail Time Aux Time Avg Talk Time Avg Hold Time Avg ACW Time APS Max Delay Totals 99 :03 298 298 12:14 0 .00 61 27 12 117:25:15 32:02:51 14:26:02 12:35 :42 :37 - :52 7:30 AM 0 0 0 0 0 0 0 0 46 54 :20:28 :09:19 :11:09 0 0 0 1 :00 8:00 AM 100 :03 25 25 7:45 0 .00 52 41 7 8:44:51 3:36:41 :36:26 10:30 :08 :13 17 :03 8:30 AM 100 :03 28 28 11:56 0 .00 58 33 9 13:05:28 4:16:28 1:13:17 15:15 :07 :40 26 :03 9:00 AM 100 :03 39 39 10:45 0 .00 59 36 6 18:58:33 6:45:56 1:05:03 14:41 :38 :35 38 :03 9:30 AM 100 :03 50 50 14:59 0 .00 56 30 14 23:15:43 7:00:40 3:13:15 13:48 :53 :49 47 :03 10:00 AM 97 :04 71 71 12:24 0 .00 66 15 19 25:14:31 3:49:30 4:51:16 11:37 :46 :44 50 :33 10:30 AM 100 :03 85 85 12:36 0 .00 65 23 12 27:45:41 6:24:17 3:15:36 11:26 :56 :33 </html> DATA; echo '<b>Total:</b><br />'; preg_match('/^Totals\s+(\d+)/m', $data, $total); print_r($total); echo '<b>Service levels:</b><br />'; preg_match_all('/^\d+:\d+\s+[AP]M\s+(\d+)/m', $data, $svc_lvl); print_r($svc_lvl); ?> </pre> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.