<?php
$a =array('1','2','3');
?>
<script language="javascript">
var obj =eval('<?php echo json_encode($a);?>');
alert(obj[0]);
alert(obj[1]);
alert(obj[2]);
</script>
PHP数组传给js
本文转载:CSDN博客
<?php
$a =array('1','2','3');
?>
<script language="javascript">
var obj =eval('<?php echo json_encode($a);?>');
alert(obj[0]);
alert(obj[1]);
alert(obj[2]);
</script>