Home >Backend Development >PHP Tutorial >How to generate an array in PHP and then pass it to js, ​​PHP generates an array in js_PHP tutorial

How to generate an array in PHP and then pass it to js, ​​PHP generates an array in js_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:21:14948browse

PHP generates an array and then passes it to js. PHP generates an array js

<script type="text/javascript">
  var slist = '<&#63;php echo urlencode(json_encode($data['arr']));&#63;>';
  var list = eval(decodeURIComponent(slist));
  drawGpsMap(list);
</script>

How to pass the value of php array to javascript array?

cannot be passed directly, but you can use js ajax to dynamically call the php array value when the page is loaded
or assign the array value processed with php as a string to the html hidden control first, and then use js code to call hidden value
In addition, I think that if your data does not change frequently, it is better to use php to generate a .js file that defines the array and then file it.

How to pass values ​​in PHP array to JS

4ec11beb6c39d0703d1751d203c17053flowplayer( "player2", "./templates/flowplayer-3.2.15.swf",{ clip: { url: "b349fb2624aab4f8b135003beffb2708", I want to replace this address with the value in the database autoPlay: false, autoBuffering: true } } ); 2cacc6d41bbb37262a98f745aa00fbf0Is this what you said?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/860470.htmlTechArticlePHP generates an array and then passes it to js. PHP generates an array js script type="text/javascript" var slist = 'php echo urlencode(json_encode($data['arr']));'; var list = eval(decodeURICompone...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn