欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

js如何获取php的数组

程序员文章站 2022-06-16 22:12:19
...
js怎么获取php的数组
php中存在省市对应数组
$info = array(
'北京'=>array('北京市'),
'福建'=>array("福州市","龙岩市","南平市","宁德市","莆田市","泉州市","三明市","厦门市","漳州市"),
'甘肃'=>array("白银市","定西市","甘南藏族自治州","嘉峪关","金昌市","酒泉市","兰州市","临夏回族自治州","陇南市","平凉市","庆阳市","天水市","武威市","张掖市"),
'广东'=>array("潮州市","东莞市","佛山市","广州市","河源市","惠州市","江门市","揭阳市","茂名市","梅州市","清远市","汕头市","汕尾市","韶关市","深圳市","阳江市","云浮市","湛江市","肇庆市","中山市","珠海市"),);


怎么在前端js或者这个数组

------解决方案--------------------
转化成json格式
echo json_encode($info);

不知道你这是ajax还是? 如果不是,那就输出一段Js 代码好了


如果是ajax ,那么JQuery的ajax json函数很好用。或者用eval("'(" + ajaxjsondata + ")'");什么的也很方便
------解决方案--------------------
HTML code


    $arr = "[[1,2,3],[2,3,4]]";
    echo $arr;
?>
js如何获取php的数组

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频