0
<script type="text/javascript">
var places = [];
</script>
<?php
$date = $_POST['orderdate'];
$file = fopen("http://www.spc.noaa.gov/climo/reports/".$date."_rpts_hail.csv", "r");
$content = fgetcsv($file, 1000, ",");
$id = 1;
while (($content = fgetcsv($file, 1000, ",")) !== FALSE) {
/*******************************************************************************************
Values of content
(ignore)****content[0] = Time*******(ignore)
content[1] = Size
(ignore)****content[2] = Location***(ignore)
content[3] = City
content[4] = State
content[5] = Lat
content[6] = Long
content[7] = Comments
*******************************************************************************************/
if ($content !== false) {
?>
<script type="text/javascript">
places.push(new google.maps.LatLng(<?php echo json_encode($content[5]); ?>, <?php echo json_encode($content[6]); ?>));
</script>
<?php
}
有沒有什麼辦法可以在頁面加載的時候運行一些PHP代碼並獲取一組信息然後將這些信息放入一個javascript變量中使用?將PHP值轉換爲javascript
@surreal在那裏爲您編輯一個原因,我沒有看到? – 2011-02-14 19:57:45