代码拉取完成,页面将自动刷新
同步操作将从 极客学长/JAreaSelect-js省市区级联选择插件 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
/**
* 整理数据,生产JavaScript数组文件
* @author yangjian<yangjian102621@gmail.com>
*/
include 'mysql_class.php';
include 'mysql_config_class.php';
header("Content-Type:text/html; charset=UTF-8");
//连接数据库
$mysql = mysql::getInstance();
$_table = "area";
/**
* 生成JavaScript数组
*/
$timer = timer();
$province = $mysql->getList("select * from {$_table} where pid=0");
$p = ''; //省份
$c = ''; //城市
$d = ''; //地区
foreach ( $province as $value ) {
if ( $p == '' ) {
$p .= "'{$value['id']}':'{$value['name']}'";
} else {
$p .= ", '{$value['id']}':'{$value['name']}'";
}
$citys = $mysql->getList("select * from {$_table} where pid={$value["id"]}");
if ( $c == '' ) {
$c .= "'{$value['id']}' : [";
} else {
$c .= ", '{$value['id']}' : [";
}
$cc = array();
foreach ($citys as $city) {
$cc[] = "{'id':'{$city['id']}', 'name':'{$city['name']}'}";
$regions = $mysql->getList("select * from {$_table} where pid={$city["id"]}");
if ( $d == '' ) {
$d .= "'{$city['id']}' : [";
} else {
$d .= ", '{$city['id']}' : [";
}
$gg = array();
foreach ($regions as $region) {
$gg[] = "{'id':'{$region['id']}', 'name':'{$region['name']}'}";
}
$d .= implode(", ", $gg)."]";
}
$c .= implode(", ", $cc)."]";
}
$buffer = "var __AREADATA__ = {\n";
$buffer .= "\t'prov' : {";
$buffer .= $p."}, \n";
$buffer .= "\t'city' : {";
$buffer .= $c."}, \n";
$buffer .= "\t'dist' : {";
$buffer .= $d."}, \n";
$buffer .= "};";
echo timer() - $timer;
if ( file_put_contents("../js/JAreaData.js", $buffer) !== FALSE ) {
echo '生成文件成功!';
}
/* print message */
function __print( $_msg ) {
echo '<pre>';
print_r($_msg);
echo '</pre>';
}
function timer() {
list($msec, $sec) = explode(' ', microtime());
return ((float)$msec + (float)$sec);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。