-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadjson.php
72 lines (56 loc) · 1.5 KB
/
loadjson.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
<?php
//********************************************************
//*********************************************************read data
/* @copyright Kathrin Braungardt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
$n=0;
$p=array();
if (($handle = fopen("wk.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 0, "\t")) !== FALSE) {
//$data[0]=strip_tags($data[0]);
$latbool=true;
//$geodaten=explode(" ", $data[0]);
$nummer=$data[0];
$latitude=$data[7];
$pos1 = stripos($latitude, ".");
if($pos1===false)
{
$latbool=false;
}
$longitude=$data[6];
$pos2 = stripos($longitude, ".");
if($pos2===false)
{
$latbool=false;
}
$long1=substr($longitude, 0,1);
$long2=substr($longitude,1);
$longitude_neu=$long1 . "." . $long2;
$regiment=trim($data[3]);
$place=trim($data[4]);
$loss=trim($data[5]);
$beschreibung=$regiment . "\n" . $loss;
$kat = explode(",", $data[4]);
if(isset($kat) && $kat[1]!=="" && count($kat)>1)
{
$kategorie=trim($kat[1]);
}
else
{
}
$ort=$data[4];
$titel1=addslashes($data[1]);
$titel2=addslashes($data[2]);
$titel=$titel1 . ", " . $titel2;
if($n>=0 && trim($latitude)!=="" && $latbool==true)
$p[] = array("nummer"=>$nummer, "latitude"=>$latitude,"longitude"=>$longitude, "beschreibung"=>$beschreibung, "titel"=>$titel, "ort"=>$ort, "kategorie"=>$kategorie);
$n++;
$kat[1]="";
}
fclose($handle);
}
$_SESSION['p']=$p;
//**********************************
$jsonData = json_encode($p);
echo $jsonData."\n";
?>