function getPlayer() { printOut("getting player"); return json_decode(file_get_contents("/var/www/html/fantasyFootball/MongoTest/player_1.json"), true); }
echo "<hr>"; if ($action === "search") { $url = "http://localhost/mahasiswa/api3.php?action=search&criteria=" . $_POST["criteria"]; $response = file_get_contents($url); $response = json_decode($response, true); if (empty($response)) { echo "Your search did not match any events"; } else { printOut($response); } } else { if ($action === "sort") { $url = "http://localhost/mahasiswa/api3.php?action=sort&criteria=" . $_POST["criteria"] . "&order=" . $_POST["order"]; $response = file_get_contents($url); $response = json_decode($response, true); printOut($response); } else { } } } else { } ?> </div> </div> </div> <!-- Page Content --> <div class="container"> <div class="center"> <div class="social-media"> <a href='https://www.facebook.com/ITB.KM'><img id="icon-fb" src="assets/home/icon-fb.png"></img></a>
function printOut($loc, $upAvg = NULL) { global $knownLocations; $avg = $knownLocations[$loc]['total'] / $knownLocations[$loc]['dealNum']; $indent = str_repeat(' ', $knownLocations[$loc]['level'] - 1); if (is_null($upAvg)) { $dev = ''; } else { $d = $avg - $upAvg; if ($d < 0) { $dd = '-$' . sprintf('%.2f', -$d); } else { $dd = '+$' . sprintf('%.2f', $d); } if ($dd === '+$0.00' || $dd === '-$0.00') { $dd = 'average'; } $dev = ' (' . $dd . ')'; } print $indent . $loc . ' $' . sprintf('%.2f', $avg) . $dev . "\n"; // print dealers global $names; $dnames = array(); foreach ($knownLocations[$loc]['dealers'] as $dname => $price) { $dnames[] = array($names[$dname], $price); } usort($dnames, function ($a, $b) { return strcmp(strtolower($a[0]), strtolower($b[0])); }); foreach ($dnames as $y) { print $indent . ' - ' . $y[0] . ' $' . $y[1] . "\n"; } // print sub-location usort($knownLocations[$loc]['children'], function ($a, $b) { return strcmp(strtolower($a), strtolower($b)); }); foreach ($knownLocations[$loc]['children'] as $child) { printOut($child, $avg); } }