示例#1
0
function setWeather()
{
    $weather = new Weather();
    $temp = $weather->getTemperature();
    $check = filter_var($temp, FILTER_VALIDATE_FLOAT);
    if (!$check) {
        return;
    }
    $temp2 = $weather->getTemperature(2);
    $code = $weather->getWeatherCode();
    $code2 = $weather->getWeatherCode(2);
    $icon = $weather->getWeatherIcon();
    $icon2 = $weather->getWeatherIcon(2);
    $description = $weather->getDescription();
    $description2 = $weather->getDescription(2);
    $id = $weather->getWeatherId();
    $id2 = $weather->getWeatherId(2);
    $date = date('Y-m-d H:i:s');
    $result = array();
    $result[] = array('code' => $code, 'temperature' => $temp, 'description' => $description, 'icon' => $icon, 'id' => $id, 'update' => $date);
    $result[] = array('code' => $code2, 'temperature' => $temp2, 'description' => $description2, 'icon' => $icon2, 'id' => $id2, 'update' => $date);
    $weather->setCachedWeather($result);
}