1. 程式人生 > >php獲取天氣例項

php獲取天氣例項

<?php if(!empty($_POST["address"])) { $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,"https://www.sojson.com/open/api/weather/json.shtml?city={$_POST['address']}"); //獲取api介面 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); $output = curl_exec($ch);
//echo $output; $arry_json=json_decode($output,true); //json_decode 將json轉化為陣列 //var_dump($arry_json); } ?>