-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.php
28 lines (25 loc) · 821 Bytes
/
stats.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
<?php
####################################################################
#
# File....: stats.php
# Function: Send dataset statistics to client
# Author..: Alexander Leipnitz
# Date....: 25.05.2020
#
######################################################################
$stats = array();
if (isset($_GET["load"])) {
// Open the file for reading
if (($h = fopen("stats.csv", "r")) !== FALSE) {
// Each line in the file is converted into an individual array that we call $data
// The items of the array are comma separated
while (($data = fgetcsv($h, 1000, ",")) !== FALSE) {
// Each individual array is being pushed into the nested array
$stats[$data[0]] = $data[1];
}
// Close the file
fclose($h);
}
echo json_encode($stats); //encode as JSON and send to client
exit;
}