国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

PHP數(shù)組轉(zhuǎn)換為js數(shù)組

dingding199389 / 1082人閱讀

摘要:背景當(dāng)我們用分層到時(shí)候,有時(shí)候需要初始化一些變量,并至的模版中,其中有一些是這種引擎解析的變量,有時(shí)候也需要來(lái)一發(fā)解析的數(shù)組變量,以下例子就是簡(jiǎn)單拼接。

背景:

當(dāng)我們用mvc分層到時(shí)候,有時(shí)候需要初始化一些變量,并assign 至view的模版中,其中有一些是smarty這種引擎解析的php變量,有時(shí)候也需要來(lái)一發(fā)js解析的數(shù)組變量,以下例子就是簡(jiǎn)單拼接。

代碼

  array (
    0 => "安徽-ah",
    101 => "合肥-hf",
    102 => "安慶-aq",
    103 => "蚌埠-bb",
    104 => "巢湖-ch",
    105 => "池州-cz",
    106 => "阜陽(yáng)-fy",
    107 => "淮北-hb",
    108 => "淮南-hn",
    109 => "六安-la",
    110 => "馬鞍山-mas",
    112 => "寧國(guó)-ng",
    113 => "銅陵-tl",
    114 => "蕪湖-wh",
    115 => "宣城-xc",
    116 => "滁州-cz",
    117 => "亳州-bz",
    118 => "黃山-hs",
    120 => "宿州-sz",
    121 => "桐城-tc",
  ),
  2 =>
  array (
    0 => "北京-bj",
    201 => "北京-bj",
  ),
  3 =>
  array (
    0 => "福建-fj",
    301 => "福州-fz",
    302 => "廈門(mén)-xm",
    303 => "龍巖-ly",
    305 => "漳州-zz",
    306 => "莆田-pt",
    307 => "泉州-qz",
    309 => "武夷山-wys",
    314 => "南平-np",
    315 => "寧德-nd",
    318 => "三明-sm",
  ),
  4 =>
  array (
    0 => "甘肅-gs",
    401 => "蘭州-lz",
    402 => "定西-dx",
    405 => "平?jīng)?pl",
    407 => "臨夏-lx",
    409 => "酒泉-jq",
    410 => "張掖-zy",
    411 => "慶陽(yáng)-qy",
    412 => "武威-ww",
    415 => "天水-ts",
    416 => "白銀-by",
    3113 => "金昌-jc",
  ),
  5 =>
  array (
    0 => "廣東-gd",
    501 => "廣州-gz",
    502 => "深圳-sz",
    503 => "珠海-zh",
    504 => "東莞-dg",
    505 => "中山-zs",
    507 => "汕頭-st",
    510 => "潮州-cz",
    511 => "韶關(guān)-sg",
    513 => "湛江-zj",
    514 => "肇慶-zq",
    515 => "茂名-mm",
    516 => "梅州-mz",
    518 => "佛山-fs",
    520 => "惠州-hz",
    521 => "江門(mén)-jm",
    522 => "揭陽(yáng)-jy",
    524 => "清遠(yuǎn)-qy",
    528 => "云浮-yf",
    532 => "陽(yáng)江-yj",
    535 => "河源-hy",
    550 => "汕尾-sw",
    1012 => "揭東-jd",
    8110 => "順德-sd",
  ),
  6 =>
  array (
    0 => "廣西-gx",
    601 => "南寧-nn",
    602 => "柳州-lz",
    603 => "桂林-gl",
    604 => "北海-bh",
    605 => "百色-bs",
    608 => "貴港-gg",
    610 => "玉林-yl",
    612 => "欽州-qz",
    613 => "梧州-wz",
    618 => "防城港-fcg",
  ),
  7 =>
  array (
    0 => "貴州-gz",
    701 => "貴陽(yáng)-gy",
    702 => "遵義-zy",
    703 => "興義-xy",
    705 => "安順-as",
    706 => "畢節(jié)-bj",
    707 => "都勻-dy",
    708 => "六盤(pán)水-lps",
    709 => "凱里-kl",
    710 => "銅仁-tr",
  ),
  8 =>
  array (
    0 => "海南-hn",
    801 => "海口-hk",
    803 => "三亞-sy",
    8101 => "儋州-dz",
  ),
  9 =>
  array (
    0 => "河北-hb",
    901 => "石家莊-sjz",
    902 => "唐山-ts",
    903 => "邢臺(tái)-xt",
    905 => "秦皇島-qhd",
    906 => "廊坊-lf",
    907 => "邯鄲-hd",
    908 => "衡水-hs",
    909 => "滄州-cz",
    910 => "保定-bd",
    911 => "張家口-zjk",
    912 => "承德-cd",
    3112 => "三河-sh",
  ),
  10 =>
  array (
    0 => "河南-hn",
    1001 => "鄭州-zz",
    1002 => "洛陽(yáng)-ly",
    1004 => "信陽(yáng)-xy",
    1005 => "新鄉(xiāng)-xx",
    1006 => "商丘-sq",
    1007 => "三門(mén)峽-smx",
    1008 => "濮陽(yáng)-py",
    1009 => "南陽(yáng)-ny",
    1011 => "焦作-jz",
    1013 => "開(kāi)封-kf",
    1014 => "安陽(yáng)-ay",
    1016 => "鶴壁-hb",
    1018 => "平頂山-pds",
    1019 => "濟(jì)源-jy",
    1021 => "駐馬店-zmd",
  ),
  21 =>
  array (
    0 => "山東-sd",
    1015 => "德州-dz",
    2101 => "濟(jì)南-jn",
    2102 => "青島-qd",
    2103 => "煙臺(tái)-yt",
    2104 => "威海-wh",
    2105 => "濰坊-wf",
    2106 => "泰安-ta",
    2107 => "棗莊-zz",
    2109 => "淄博-zb",
    2110 => "東營(yíng)-dy",
    2111 => "高密-gm",
    2112 => "菏澤-hz",
    2113 => "濱州-bz",
    2114 => "聊城-lc",
    2117 => "臨沂-ly",
    2118 => "濟(jì)寧-jn",
    2120 => "日照-rz",
  ),
  11 =>
  array (
    0 => "黑龍江-hlj",
    1101 => "哈爾濱-heb",
    1102 => "大慶-dq",
    1103 => "齊齊哈爾-qqhe",
    1104 => "鶴崗-hg",
    1106 => "佳木斯-jms",
    1107 => "雞西-jx",
    1108 => "牡丹江-mdj",
    1112 => "伊春-yc",
    1116 => "綏化-sh",
    1118 => "雙鴨山-sys",
  )
);
 function get_provice_city_js($arrData=[],$jsVarName=""){

  $js_result="";
  $intCount=0;
   foreach($arrData as $intProv => $arrAreaData)
                {
                    $js_result .= $jsVarName."[".$intCount++."] = new Array("".$intProv."-".$arrAreaData[0].""";

                    //再循環(huán)省下面的城市
                    foreach($arrAreaData as $intCity => $strCity)
                    {

                      //如果是省份,忽略
                        if ($intCity == 0) {
                            continue;
                        }

                        $js_result .= ","".$intCity."-".$strCity.""";
                    }
                    $js_result .= ");"."
";
                }
                return $js_result;

}

echo get_provice_city_js($php_array,"myProject.");
輸出
myProject.[0] = new Array("1-安徽-ah","101-合肥-hf","102-安慶-aq","103-蚌埠-bb","104-巢湖-ch","105-池州-cz","106-阜陽(yáng)-fy","107-淮北-hb","108-淮南-hn","109-六安-la","110-馬鞍山-mas","112-寧國(guó)-ng","113-銅陵-tl","114-蕪湖-wh","115-宣城-xc","116-滁州-cz","117-亳州-bz","118-黃山-hs","120-宿州-sz","121-桐城-tc");
myProject.[1] = new Array("2-北京-bj","201-北京-bj");
myProject.[2] = new Array("3-福建-fj","301-福州-fz","302-廈門(mén)-xm","303-龍巖-ly","305-漳州-zz","306-莆田-pt","307-泉州-qz","309-武夷山-wys","314-南平-np","315-寧德-nd","318-三明-sm");
myProject.[3] = new Array("4-甘肅-gs","401-蘭州-lz","402-定西-dx","405-平?jīng)?pl","407-臨夏-lx","409-酒泉-jq","410-張掖-zy","411-慶陽(yáng)-qy","412-武威-ww","415-天水-ts","416-白銀-by","3113-金昌-jc");
myProject.[4] = new Array("5-廣東-gd","501-廣州-gz","502-深圳-sz","503-珠海-zh","504-東莞-dg","505-中山-zs","507-汕頭-st","510-潮州-cz","511-韶關(guān)-sg","513-湛江-zj","514-肇慶-zq","515-茂名-mm","516-梅州-mz","518-佛山-fs","520-惠州-hz","521-江門(mén)-jm","522-揭陽(yáng)-jy","524-清遠(yuǎn)-qy","528-云浮-yf","532-陽(yáng)江-yj","535-河源-hy","550-汕尾-sw","1012-揭東-jd","8110-順德-sd");
myProject.[5] = new Array("6-廣西-gx","601-南寧-nn","602-柳州-lz","603-桂林-gl","604-北海-bh","605-百色-bs","608-貴港-gg","610-玉林-yl","612-欽州-qz","613-梧州-wz","618-防城港-fcg");
myProject.[6] = new Array("7-貴州-gz","701-貴陽(yáng)-gy","702-遵義-zy","703-興義-xy","705-安順-as","706-畢節(jié)-bj","707-都勻-dy","708-六盤(pán)水-lps","709-凱里-kl","710-銅仁-tr");
myProject.[7] = new Array("8-海南-hn","801-海口-hk","803-三亞-sy","8101-儋州-dz");
myProject.[8] = new Array("9-河北-hb","901-石家莊-sjz","902-唐山-ts","903-邢臺(tái)-xt","905-秦皇島-qhd","906-廊坊-lf","907-邯鄲-hd","908-衡水-hs","909-滄州-cz","910-保定-bd","911-張家口-zjk","912-承德-cd","3112-三河-sh");
myProject.[9] = new Array("10-河南-hn","1001-鄭州-zz","1002-洛陽(yáng)-ly","1004-信陽(yáng)-xy","1005-新鄉(xiāng)-xx","1006-商丘-sq","1007-三門(mén)峽-smx","1008-濮陽(yáng)-py","1009-南陽(yáng)-ny","1011-焦作-jz","1013-開(kāi)封-kf","1014-安陽(yáng)-ay","1016-鶴壁-hb","1018-平頂山-pds","1019-濟(jì)源-jy","1021-駐馬店-zmd");
myProject.[10] = new Array("21-山東-sd","1015-德州-dz","2101-濟(jì)南-jn","2102-青島-qd","2103-煙臺(tái)-yt","2104-威海-wh","2105-濰坊-wf","2106-泰安-ta","2107-棗莊-zz","2109-淄博-zb","2110-東營(yíng)-dy","2111-高密-gm","2112-菏澤-hz","2113-濱州-bz","2114-聊城-lc","2117-臨沂-ly","2118-濟(jì)寧-jn","2120-日照-rz");
myProject.[11] = new Array("11-黑龍江-hlj","1101-哈爾濱-heb","1102-大慶-dq","1103-齊齊哈爾-qqhe","1104-鶴崗-hg","1106-佳木斯-jms","1107-雞西-jx","1108-牡丹江-mdj","1112-伊春-yc","1116-綏化-sh","1118-雙鴨山-sys");
[Finished in 0.1s]

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/89211.html

相關(guān)文章

  • PHP數(shù)組轉(zhuǎn)換js數(shù)組

    摘要:背景當(dāng)我們用分層到時(shí)候,有時(shí)候需要初始化一些變量,并至的模版中,其中有一些是這種引擎解析的變量,有時(shí)候也需要來(lái)一發(fā)解析的數(shù)組變量,以下例子就是簡(jiǎn)單拼接。 背景: 當(dāng)我們用mvc分層到時(shí)候,有時(shí)候需要初始化一些變量,并assign 至view的模版中,其中有一些是smarty這種引擎解析的php變量,有時(shí)候也需要來(lái)一發(fā)js解析的數(shù)組變量,以下例子就是簡(jiǎn)單拼接。 代碼

    cyrils 評(píng)論0 收藏0
  • PHPJS數(shù)組轉(zhuǎn)換

    因?yàn)槌绦蛴玫剑坝譀](méi)寫(xiě)過(guò),費(fèi)了很大的勁才寫(xiě)出來(lái)。 主要是編輯文章部分,讀取,修改關(guān)鍵詞 發(fā)布文章部分 //定義JS的數(shù)組 var tagslist = []; //然后把用戶輸入的標(biāo)簽添加到這個(gè)數(shù)組里 tagslist.push(測(cè)試1); //發(fā)送到后臺(tái)的時(shí)候進(jìn)行了編碼,ECMAScript v3 反對(duì)使用escape,所以盡量不用了 encodeURI(tagslist) //后臺(tái)接...

    scq000 評(píng)論0 收藏0
  • PHPJS數(shù)組轉(zhuǎn)換

    因?yàn)槌绦蛴玫剑坝譀](méi)寫(xiě)過(guò),費(fèi)了很大的勁才寫(xiě)出來(lái)。 主要是編輯文章部分,讀取,修改關(guān)鍵詞 發(fā)布文章部分 //定義JS的數(shù)組 var tagslist = []; //然后把用戶輸入的標(biāo)簽添加到這個(gè)數(shù)組里 tagslist.push(測(cè)試1); //發(fā)送到后臺(tái)的時(shí)候進(jìn)行了編碼,ECMAScript v3 反對(duì)使用escape,所以盡量不用了 encodeURI(tagslist) //后臺(tái)接...

    kycool 評(píng)論0 收藏0
  • 前端知識(shí)點(diǎn)總結(jié)——AJAX

    摘要:對(duì)象的語(yǔ)法對(duì)象名屬性值屬性值屬性值屬性值林黛玉這個(gè)對(duì)象所對(duì)應(yīng)的屬性如下林黛玉如果對(duì)象取值的時(shí)候,直接對(duì)象屬性名稱就可以林黛玉什么是對(duì)象表現(xiàn)方式對(duì)象表示法,即以對(duì)象的格式表現(xiàn)出來(lái)的字符串。 前端知識(shí)點(diǎn)總結(jié)——Ajax 1.ajax 1.URL的作用 用于表示任意一個(gè)資源的位置(互聯(lián)網(wǎng)上) 2.詳解 格式: ://:@:/;?# scheme:方案協(xié)議,以哪種方式到服務(wù)獲...

    hzc 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

dingding199389

|高級(jí)講師

TA的文章

閱讀更多
最新活動(dòng)
閱讀需要支付1元查看
<