/
text.php
75 lines (53 loc) · 1.32 KB
/
text.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Extract a text from a text file which start with a text pattern
*/
function extractFromTextFile($file, $textPattern) {
$fh = fopen($file,'r');
$menuFound = false;
$menuText = '';
while ($line = fgets($fh)) {
if($menuFound) {
if($line == PHP_EOL) {
break;
}
$menuText = $menuText . $line;
} else {
if (strpos(strtoupper($line),strtoupper($textPattern)) !== false) {
$menuFound = true;
}
}
}
fclose($fh);
return $menuText;
}
function extractFromTextFile2($file, $textPattern) {
$fh = fopen($file,'r');
$menuFound = false;
$menuText = '';
while ($line = fgets($fh)) {
if($menuFound) {
$menuText = $line;
break;
} else {
if (strpos(strtoupper($line),strtoupper($textPattern)) !== false) {
$menuFound = true;
}
}
}
fclose($fh);
return $menuText;
}
$day = 'mardi 24';
echo '<br />';
echo utf8_encode(extractFromTextFile('pdf_texts\pinocchio.txt', $day));
echo '<br />';
echo utf8_encode(extractFromTextFile('pdf_texts\pinocchio.txt', 'Le Hit de la semaine'));
echo '<br />';
echo utf8_encode(extractFromTextFile('pdf_texts\pinocchio.txt', 'Menu 3'));
echo '<br />';
echo utf8_encode(extractFromTextFile('pdf_texts\pinocchio.txt', 'Menu 4'));
$day = 'Mardi 1';
echo '<br /><h1>Boc</h1>';
echo utf8_encode(extractFromTextFile2('pdf_texts\boc.txt', $day));
?>