Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<pre>";
- include('lib/PdfToText.phpclass');
- $time_pattern1 = '/(\d{2}:\d{2}:\d{2} [A-Za-z]{2})/';
- $time_pattern2 = '/(\d{2}:\d{2} [A-Za-z]{2})/';
- $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)+/';
- $pdf = new PdfToText('schedule 10 efcc sample.pdf');
- //print_r($pdf->Text);
- //exit();
- $physicians = array();
- $text = preg_replace($space_utf_pattern, ' ', $pdf->Text);
- $header = explode(' ', substr($text, 0, 200));
- foreach ($header as $key => $value)
- {
- if($value=='Visits:') $physicians[] = str_replace('Time', '', $header[$key-1]);
- }
- //print_r($physicians);
- $text = preg_replace('/Schedule[\s\S]+?2018/', '', $text);
- if(preg_match($time_pattern1, $text))
- {
- //$data_raw = preg_split($time_pattern1, $text, NULL, PREG_SPLIT_DELIM_CAPTURE);
- }
- if(preg_match($time_pattern2, $text))
- {
- $data_raw = preg_split($time_pattern2, $text, NULL, PREG_SPLIT_DELIM_CAPTURE);
- }
- //print_r($data_raw);
- for($i=1; $i<count($data_raw); $i++) {
- if($i%2==0)
- {
- //$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]);
- $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]));
- $data_raw[$i] = preg_replace('/\s+/', ' ', trim($data_raw[$i]));
- $data[$data_raw[$i-1]] = $data_raw[$i];
- }
- }
- $tmparraykeys = array();
- foreach($data as $key => $value)
- {
- $tmpstr = preg_split('/(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))/', $value,NULL, PREG_SPLIT_DELIM_CAPTURE);
- $tmparr_nameandphone = preg_split('/\s+/', $tmpstr[1]);
- $tmparrayvalues = array($tmpstr[0],$tmparr_nameandphone[1],$tmparr_nameandphone[0],);
- $tmparrayvalues[0] = preg_split('/(\d{2})/', $tmparrayvalues[0]);
- $tmparraykeys['name'] = $tmparrayvalues[0][0];
- $tmparraykeys['phone'] = $tmparrayvalues[1];
- $tmparraykeys['min'] = $tmparrayvalues[2];
- $data2[$key] = $tmparraykeys;
- //$data2[$key][phonenumber] = $tmparr[0];
- }
- //print_r($data2);
- //exit;
- foreach($data2 as $key => $arrtmp) {
- print_r($arrtmp);
- foreach($data2 as $arrtmp=>$value)
- {
- //$pieces = explode(' ', $value);
- $pieces = $value;
- $data[$arrtmp] = @array($physicians[0]=>$pieces[0].' '.$pieces[1],
- $physicians[1]=>$pieces[2].' '.$pieces[3]);
- }
- }
- //print_r($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement