Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.66 KB | None | 0 0
  1. <?php
  2. echo "<pre>";
  3. include('lib/PdfToText.phpclass');
  4. $time_pattern1       = '/(\d{2}:\d{2}:\d{2} [A-Za-z]{2})/';
  5. $time_pattern2      = '/(\d{2}:\d{2} [A-Za-z]{2})/';
  6. $space_utf_pattern  = '/(\t|\n|\v|\f|\r| |\xC2\x85|\xc2\xa0|\xe1\xa0\x8e|\xe2\x80[\x80-\x8D]|\xe2\x80\xa8|\xe2\x80\xa9|\xe2\x80\xaF|\xe2\x81\x9f|\xe2\x81\xa0|\xe3\x80\x80|\xef\xbb\xbf)+/';
  7. $pdf                = new PdfToText('schedule 10 efcc sample.pdf');
  8.  
  9. //print_r($pdf->Text);
  10. //exit();
  11. $physicians = array();
  12. $text = preg_replace($space_utf_pattern, ' ', $pdf->Text);
  13. $header = explode(' ', substr($text, 0, 200));
  14. foreach ($header as $key => $value)
  15. {
  16.     if($value=='Visits:') $physicians[] = str_replace('Time', '', $header[$key-1]);
  17. }
  18. //print_r($physicians);
  19. $text = preg_replace('/Schedule[\s\S]+?2018/', '', $text);
  20.  
  21. if(preg_match($time_pattern1, $text))
  22. {
  23.     //$data_raw = preg_split($time_pattern1, $text, NULL, PREG_SPLIT_DELIM_CAPTURE);
  24. }
  25. if(preg_match($time_pattern2, $text))
  26. {
  27.     $data_raw = preg_split($time_pattern2, $text, NULL, PREG_SPLIT_DELIM_CAPTURE);
  28. }
  29.  
  30. //print_r($data_raw);
  31. for($i=1; $i<count($data_raw); $i++) {
  32.     if($i%2==0)
  33.     {
  34.         //$data_raw[$i] = preg_replace('/\s*\([^)]*\)|F\/U|Fully Booked\.|Checked In|OVERBOOKED|Booked|\d{2} MINUTES\.|Missed|FM|See ACPM|Comment|^(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))*$/', '', $data_raw[$i]);
  35.         $data_raw[$i] = preg_replace('/\s*\([^)]*\)|f\/u|fully booked\.|checked in|overbooked|booked|\d{2} minutes\.|missed|FM|see acpm|comment/', '', strtolower($data_raw[$i]));
  36.         $data_raw[$i] = preg_replace('/\s+/', ' ', trim($data_raw[$i]));
  37.         $data[$data_raw[$i-1]] = $data_raw[$i];
  38.     }
  39. }
  40.     $tmparraykeys = array();
  41. foreach($data as $key => $value)
  42. {
  43.  
  44.     $tmpstr = preg_split('/(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))/', $value,NULL, PREG_SPLIT_DELIM_CAPTURE);
  45.     $tmparr_nameandphone = preg_split('/\s+/', $tmpstr[1]);
  46.     $tmparrayvalues = array($tmpstr[0],$tmparr_nameandphone[1],$tmparr_nameandphone[0],);
  47.     $tmparrayvalues[0] = preg_split('/(\d{2})/', $tmparrayvalues[0]);
  48.     $tmparraykeys['name']   = $tmparrayvalues[0][0];
  49.     $tmparraykeys['phone']  = $tmparrayvalues[1];
  50.     $tmparraykeys['min']    = $tmparrayvalues[2];
  51.     $data2[$key]            = $tmparraykeys;
  52.     //$data2[$key][phonenumber] = $tmparr[0];
  53. }
  54. //print_r($data2);
  55. //exit;
  56. foreach($data2 as $key => $arrtmp) {
  57.     print_r($arrtmp);
  58.     foreach($data2 as $arrtmp=>$value)
  59.     {
  60.     //$pieces = explode(' ', $value);
  61.         $pieces = $value;
  62.     $data[$arrtmp] = @array($physicians[0]=>$pieces[0].' '.$pieces[1],
  63.                          $physicians[1]=>$pieces[2].' '.$pieces[3]);
  64.     }
  65. }
  66. //print_r($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement