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
<script type="text/javascript"> var slist = '<?php echo urlencode(json_encode($data['arr']));?>'; var list = eval(decodeURIComponent(slist)); drawGpsMap(list); </script>
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.
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?