:::

6-9 /get_json.php

<?php
/**
 * Phone Book module
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright  The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license    http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package    Phone Book
 * @since      2.5
 * @author     tad
 * @version    $Id $
 **/

/*-----------引入檔案區--------------*/
include "header.php";

/*-----------功能函數區--------------*/
$content=file_get_contents("http://gis.taiwan.net.tw/XMLReleaseALL_public/restaurant_C_f.json");
$content=removeBOM($content);
$arr=json_decode($content,true);

$myts = MyTextSanitizer::getInstance();

foreach ($arr['Infos']['Info'] as $key => $value) {
  foreach ($value as $k => $v) {
    $$k=$myts->addSlashes($v);
  }
  $sql="insert into `" . $xoopsDB->prefix("restaurant") . "` (`Zipcode`, `Name` ,`Description` ,`Add` ,`Website`) values('$Zipcode', '$Name' , '$Description', '$Add' ,'$Website')";
  $xoopsDB->queryF($sql) or web_error($sql);
}

echo "ok";

//移除BOM
function removeBOM($str = '')
{
    if (substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf))
        $str = substr($str, 3);

    return $str;
}

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1256%26tbsn%3D39

書籍目錄

展開 | 闔起

線上使用者

38人線上 (9人在瀏覽線上書籍)

會員: 0

訪客: 38

更多…