-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.php
47 lines (35 loc) · 944 Bytes
/
data.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
<?php
# This index page is purely for demonstation purposes.
require_once 'GetSpreadsheetData.class.php';
$spreadsheetId = "1B40WXBz1d3zkR5-ZFieKiannA-WGScUEf3MANYI0jo0";
$GetSpreadsheetData = new GetSpreadsheetData($spreadsheetId);
$i = 0;
$lang = "en";
$results = [];
if(!$data = $GetSpreadsheetData->returnData()) {
die();
}
foreach($data as $row) {
$currentRow = array();
// Build each result / row out
foreach ($row as $key => $value) {
$dontWant = ['id', 'updated', 'category', 'title', 'content', 'link'];
if (in_array($key, $dontWant)) {
continue;
}
if ( strpos($key, 'gsx$') !== -1 ) {
$cleanLabel = str_replace('gsx$', '', $key);
// $cleanLabel = $key;
$currentRow[$cleanLabel] = $value->{'$t'};
}
}
array_push($results, $currentRow);
}
// Must check...
try {
$jsonData = json_encode($results);
} catch (Exception $e) {
print_r($e);
}
print_r( $jsonData );
?>