I’m now implement such a task:I need to convert PHP variables to javascript
$arr['name1'] = 'value1';
$arr['name2'] = 'value2';
so that after processing,should be:
<script type="text/javascript">
var name1 = 'value1';
var name2 = 'value2';
...
I hoped to do it this way:
<script>
list(<?php echo join(',',array_keys($arr)?>) = <?php echo json_encode(array_values($arr));?>
Probably misunderstood the question, but wouldn’t this work?