PHP生成数组再传给js的方法,php生成数组js
<script type="text/javascript"> var slist = '<?php echo urlencode(json_encode($data['arr']));?>'; var list = eval(decodeURIComponent(slist)); drawGpsMap(list); </script>
不能直接传递,但是可以用js的ajax在页面加载的时候动态调用php数组值
或者把用php处理的数组值当字符串先赋值给html hidden控件,然后用js代码调用hidden的value
另外我觉得,如果你的这个数据不是经常改变的话,最好是用php生成一个.js文件,这个文件就定义这个数组,然后file一下,比较好

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor