-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
executable file
·51 lines (39 loc) · 1.37 KB
/
test.php
File metadata and controls
executable file
·51 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
ini_set("display_errors",1);
$path = "./";
$data=[];
$i=0;
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ( ('.' === $file || '..' === $file) ){ continue; }
elseif(is_file($file) && pathinfo($file, PATHINFO_EXTENSION)=='ppt'){
$file_data = file_get_contents($file);
$file_data = preg_replace("/[^a-zA-Z0-9 ]/", "", $file_data);
#echo stripos($file_data, "calibri "); die;
#echo strpos($file_data, 'Odb6D'); die;
$start = (strpos($file_data,'Title 1dT')+9);
$end = strpos($file_data, 'CGgn');
$dname = substr($file_data, $start, ($end - $start) );
$emp_name = substr($dname, 0,strpos($dname, ' '));
$designation = substr($dname,(strpos($dname, ' ')+3 ));
$emp_code = (int)substr($file_data,(stripos($file_data, "emp code ")+9), 10);
$data[$i]['emp_code'] = $emp_code;
$data[$i]['emp_name'] = $emp_name;
$data[$i]['designation'] = $designation;
$i++;
}
// do something with the file
}
closedir($handle);
}
echo "<pre>";
print_r($data);
$file_name = 'data.csv';
$fp = fopen($file_name,'w') or die("Unable to open file!");
$csv_headers = ['Emp Code',"Emp Name","Designation"];
fputcsv($fp, $csv_headers);
foreach ($data as $rows) {
fputcsv($fp, $rows);
}
fclose($fp);
return $file_name;