<?php /** * If the suburb is not set then we don't need to send it because it will just default to the major city */ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && isset($_POST['state'])) { require_once '../Kuttner/Load.php'; $load = new Kuttner\Library\Load(); if (isset($_POST['suburb'])) { $maxTemp = $load->weather($_POST['state'], $_POST['suburb']); } else { $maxTemp = $load->weather($_POST['state']); } echo json_encode($maxTemp); } else { echo 'fail'; }
<?php ini_set('display_errors', 1); error_reporting(E_ALL); //You just need to require Load.php require_once '../src/bom-weather/Kuttner/Load.php'; $load = new Kuttner\Library\Load(); //The second attribute is optional you can just supply the state prefix it will default to the major city. //This will return an array. $maxTemps = $load->weather('nsw', 'sydney'); $x = 0; foreach ($maxTemps as $day => $values) { $suburb = $values['suburb']; if ($x === 0) { echo ucfirst($suburb) . '<hr>'; $x++; } echo ucfirst($day) . ': ' . $values['maxTemp'] . ' - Icon: ' . $values['iconCode'] . '<br>'; }