Skip to content

Commit d9628d7

Browse files
authored
Merge pull request #103 from Shaswat975/json-schema-notices
Created JSON Schema to print Notices
2 parents 7302bca + 98d6b45 commit d9628d7

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

Diff for: webroot/api/notices/index.php

+10-15
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@
44

55
require_once "../../../resources/autoload.php";
66

7-
if (isset($_GET["line_wrap"])) {
8-
$CHAR_WRAP = $_GET["line_wrap"];
9-
} else {
10-
$CHAR_WRAP = 80;
11-
}
12-
137
$notices = $SQL->getNotices();
8+
$jsonArray = [];
149
foreach ($notices as $notice) {
15-
echo $notice["title"] . "\r\n";
16-
echo date('m-d-Y', strtotime($notice["date"])) . "\r\n";
17-
18-
$lineArr = explode("\r\n", wordwrap($notice["message"], $CHAR_WRAP));
19-
foreach ($lineArr as $line) {
20-
echo $line;
21-
}
22-
23-
echo "\r\n\r\n";
10+
$formattedNotice = [
11+
"title" => $notice["title"],
12+
"date" => date('m-d-Y', strtotime($notice["date"])),
13+
"message" => $notice["message"]
14+
];
15+
$jsonArray[] = $formattedNotice;
2416
}
17+
18+
$jsonOutput = json_encode($jsonArray, JSON_PRETTY_PRINT);
19+
echo $jsonOutput;

0 commit comments

Comments
 (0)