How does js obtain php arrays?

Source: Internet
Author: User
How does js obtain the php array? the corresponding array of provinces and cities exists in php & nbsp; $ infoarray (& nbsp; Beijing & gt; array (Beijing), & nbsp; Fujian & gt; array (& quot; Fuzhou & quot;, & quot; Longyan City & quot;, & quot; Nanping City & quot;, & quot; Ningde City & quot;, & quot; how to get php array in Putian js
Php contains arrays corresponding to provinces and cities
$ Info = array (
'Beijing' => array ('Beijing '),
'Fujian '=> array ("Fuzhou City", "Longyan City", "Nanping City", "Ningde City", "Putian City", "Quanzhou", "Sanming City", "Xiamen city ", "Zhangzhou City "),
'Gansu '=> array ("Baiyin City", "Dingxi City", "Gannan Tibetan autonomous prefecture", "jiayuguan", "Jinchang city", "Jiuquan City", "Lanzhou City ", "Linxia Hui autonomous prefecture", "Longnan city", "Pingliang city", "Qingyang City", "Tianshui City", "Wuwei city", "Changzhi City "),
'Guangdong '=> array ("Chaozhou city", "Dongguan City", "Foshan City", "Guangzhou City", "Heyuan City", "Huizhou City", "Jiangmen City", "Jieyang city ", "Maoming city", "Meizhou City", "Qingyuan city", "Shantou city", "Shanwei City", "Shaoguan city", "Shenzhen City", "Yangjiang City", "Yunfu city", "Zhanjiang City ", "Zhaoqing City", "Zhongshan city", "Zhuhai City "),);


In front-end js or this array

------ Solution --------------------
Convert to json format
Echo json_encode ($ info );

I don't know if this is ajax or? If not, output a piece of Js code.
Script
Var jsondata = ;
Script

For ajax, JQuery's ajax json function is very useful. Or use eval ("'(" + ajaxjsondata + ")'").
------ Solution --------------------
HTML code
  《script》    var tmp = '
  ';    tmp = eval('('+tmp+')')    alert(tmp.length)《script》 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.