序列化
1. <?php $arr = array("大理","昆明"); $json = json_encode($arr); ?> <script> var jsarr = <?php echo $json;?>; alert(jsarr[0]); </script> 2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>第一php网提供的教程--向JS传递PHP数组</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"/></script> <script language=javascript> function get_php_arr(arr){ alert(eval(arr))