-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatAnswer.php
49 lines (38 loc) · 1.29 KB
/
formatAnswer.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
<?php
// Format the answer;
function formatAnswer($getAnswers)
{
$content = '';
$content .= '<pre>';
// Create buld Inventory
$build_inventory = [];
for ($i = 0; $i < count($getAnswers->return_all); $i++) {
// Remove all inventory items that may return null
if (!isset($getAnswers->return_all[$i]->inventory)) {
continue;
}
// Push all inventory items to a single array
if ($getAnswers->return_all[$i]->inventory) {
array_push($build_inventory, $getAnswers->return_all[$i]->inventory);
}
}
// Filter our similar items in to groups
$build_inventory = array_count_values($build_inventory);
foreach ($build_inventory as $key => $value) {
$content .= 'Number of <b>' . $key . '</b> items is ' . $value . '<br>';
}
$content .= '</pre>';
$content .= '<small>';
$getLog = $getAnswers->log;
// Loop around error logs
for ($i = 0; $i < count($getLog); $i++) {
$content .= 'The Conveyer Belt Moves....' . '<br>';
for ($x = 0; $x < count($getLog[$i]); $x++) {
for ($z = 0; $z < count($getLog[$i][$x]); $z++) {
$content .= $getLog[$i][$x][$z] . '<br>';
}
}
}
$content .= '</small>';
return $content;
}