-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseStops.php
53 lines (49 loc) · 1.35 KB
/
parseStops.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
<?php
header("Content-Type: text/html; charset=utf-8");
$url = "https://www.its-rnd.ru/pikasonline/rostov/stops.txt";
$txt = file_get_contents($url);
$handle = fopen($url, "r");
$array = array();
while (($line = fgets($handle)) !== false) {
$array[] = $line;
}
fclose($handle);
$array1 = array();
for ($i = 0; $i < count($array); $i++) {
$array2 = split(';', $array[$i]);
$array1[] = array(
"id" => $array2[0],
"Lat" => $array2[1],
"Lng" => $array2[2],
"Stops" => $array2[3],
"Name" => $array2[4],
);
}
$mysqli = @new mysqli('mysql.daminik00.myjino.ru', 'daminik00', 'luabeo', 'daminik00_routes');
if (mysqli_connect_errno()) {
echo "Подключение невозможно: ".mysqli_connect_error();
}
$mysqli->query ("SET NAMES 'utf8'");
for ($i = 0; $i < count($array1); $i++) {
$mysqli->query ("
INSERT INTO `stops` (
`id`,
`Lat`,
`Lng`,
`Stops`,
`Name`
) VALUES (
'{$array1[$i]['id']}',
'{$array1[$i]['Lat']}',
'{$array1[$i]['Lng']}',
'{$array1[$i]['Stops']}',
'{$array1[$i]['Name']}'
)
");
}
print_r($array1);
// "Info" => $array2[5],
// "Street" => $array2[6],
// "Area" => $array2[7],
// "City" => $array2[8],
?>