码迷,mamicode.com
首页 > 编程语言 > 详细

PHP的数组值传入JavaScript的数组里

时间:2015-12-09 01:49:36      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>PHP的数组值传入JavaScript的数组里</title>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript">
var arr=new Array(4);
    arr[0] = "George"
    arr[1] = "John"
    arr[2] = "Thomas"
    arr[3] = "James"
var i=9;
</script>

<?php
   $array=array("88","99","66","你好");
   echo"<script>Array=$array</script>";
?>

<script language="JavaScript">
var arr = <?php echo json_encode($array)?>;
alert(arr[3]);
</script>

</head>
<body>
 网页页面!
</body>
</html>

PHP的数组值传入JavaScript的数组里

标签:

原文地址:http://www.cnblogs.com/qingsong/p/5031502.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!