-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.php
More file actions
34 lines (27 loc) · 842 Bytes
/
diff.php
File metadata and controls
34 lines (27 loc) · 842 Bytes
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
<?php
function loadJson($fileName){
if(!is_file($fileName)){
return [];
}
return json_decode(file_get_contents($fileName),true);
}
$allDifs = [];
$data = loadJson("generated/total/country.json");
$diffs = [0];
for($i = 1; $i < count($data); $i++) {
$current = $data[$i];
$previous = $data[$i - 1];
$diffs[] = round((1 - ($previous / $current)) * 100, 2);
}
$allDifs['Tüm Türkiye'] = $diffs;
$data = loadJson("generated/total/city.json");
foreach($data as $cityName => $values) {
$diffs = [0];
for($i = 1; $i < count($values); $i++) {
$current = $values[$i];
$previous = $values[$i - 1];
$diffs[] = round((1 - ($previous / $current)) * 100, 2);
}
$allDifs[$cityName] = $diffs;
}
file_put_contents('generated/diffs.json',json_encode($allDifs,JSON_PRETTY_PRINT));