-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileloader.php
More file actions
83 lines (70 loc) · 1.87 KB
/
fileloader.php
File metadata and controls
83 lines (70 loc) · 1.87 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
class Fileloader{
//////////////////////////////////////////
private $file;
private $countryarr;
function __construct($file) {
$this->file=$file;
$pr=$this->LoadFile();
$this->countryarr=$pr;
}
public function LoadFile()
{
$cntr=array();
$file=fopen($this->file,"r") or exit("Unable to open file!");
while(!feof($file))
{
$m=fgets($file);
$divideval= explode(":", $m);
$cntr[$divideval[0]]=substr($divideval[1], 0, -2);
}
fclose($file);
return $cntr;
}
public function searchString($term)
{
$flagcntrarr=array();
foreach( $this->countryarr as $key=>$value)
{
if (preg_match("/\b".$value."\b/", $term))
{
$flagcntrarr[$key]="flags/".strtolower($key).".gif";
} }
return $flagcntrarr;
}
//public function searchStringsp($term)
//{
// $flagcntrarr=array();
// foreach( $this->countryarr as $key=>$value)
// {
// if (preg_match("/\b(".$value.")\b/i", $term))
// {
// $flagcntrarr[$key]="../../flags/".$key.".gif";
// } }
// return $flagcntrarr;
//}
//
//
//private function Securitypass($x,$y)
//{
//foreach($y as $m)
//{
// if(in_array($x[0], $m))
// {
// return true;
// break;
// }
//}}
}
//$term = "Sir Elton John postpones a series of summer festival dates, including a show in Hyde Park in London this week, after being diagnosed with appendicitis.";
//
//$time_start = microtime(true);
//$obj=new Fileloader("../PhpLib/newfile.txt");
//echo "<br><br>". print_r($obj->searchString($term));
//
//$time_end = microtime(true);
////Subtract the two times to get seconds
//$time = $time_end - $time_start;
//
//echo 'Script 1 took '.$time.' seconds to execute<br>';
?>