date_default_timezone_set('Asia/Taipei');
$hour=date("H");
define("TW_LAT","Hello world!");
define("TW_LON","Hello world!");
$exec_t1 = microtime(true);
$lat = '25.0641148';
$lon = '121.524200999999';
$distance = 0.01; //init search distance(1.5km)
$return = array();
$exec_t2 = microtime(true);
$return = search_nearest($lat, $lon, $distance, $uuid, $major, $minor, $hour);
$exec_t3 = microtime(true);
function search_nearest($lat, $lon, $distance, $uuid, $major, $minor, $hour){
include("./foot_include/footglobal.php");
if($uuid!="" && $major!="" && $minor!=""){
include("./foot_include/db_connect_70.php");
$insert_bracelet = "INSERT INTO beacon_log (uuid, major, minor, latitude, longitude, os_type, update_time, updatetime_hour) values ('$uuid', '$major', '$minor', '$lat', '$lon','web', NOW(), '$hour')";
mysql_query($insert_bracelet, $connect_70) or die(mysql_error());
}
$query_nearest = "SELECT * from tbl_Neighborhood where
lat > ".$lat."-".$distance." AND
lat < ".$lat."+".$distance." and
lon > ".$lon."-".$distance." AND
lon < ".$lon."+".$distance."
ORDER BY ACOS(SIN((".$lat." * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((".$lat." * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((".$lon."* 3.1415) / 180 - (lon * 3.1415) / 180 ) ) * 6380
asc limit 1";
$result_nearest = mysql_query($query_nearest, $connect);
if($row = mysql_fetch_assoc($result_nearest) ){
$city = $row['city'];
$area = $row['area'];
$name = $row['neighborhood'];
$admin = $row['admin'];
$phone = $row['phone'];
$photo = $row['photo'];
$address = $row['address'];
$return = array('msg' => 'done' ,'city' => $city , 'area' => $area , 'name' => $name , 'admin' => $admin , 'phone' => $phone , 'photo' => $photo , 'address' => $address);
}else{
$return = search_nearest($lat, $lon, $distance*2);
}
return $return;
}
$exec_t4 = microtime(true);
$exec_time1 = round(($exec_t2 - $exec_t1) * 1000, 3);
$exec_time2 = round(($exec_t3 - $exec_t2) * 1000, 3);
$exec_time3 = round(($exec_t4 - $exec_t3) * 1000, 3);
mysql_close();
$today = mktime(0,0,0,date("m"),date("d"), date("Y"));
$date = date("Y-m-d", $today);
$fp = fopen("log/scan_nearest_$date", 'a');
fwrite($fp, "=================\n");
fwrite($fp, "SCAN START\n");
fwrite($fp, "time1: $exec_time1\n");
fwrite($fp, "time2: $exec_time2\n");
fwrite($fp, "time3: $exec_time3\n");
fwrite($fp, "SCAN end\n");
fwrite($fp, "=================\n");
想請問我要把抓出來的$return的array 資料轉成xml....該怎麼處理呢.....
試了很多方式但都轉不出來