<script type="text/javascript"> var a = new Array(); a = "a"; a = "b"; a = "c"; a = "d"; // alert(a[0]) for(var i=0; i<a.length; i++){ console.log(i + " " + a[i]); } </script>
<?php $Cities[] = "<B>北京</B>"; //等同于$Cities[0] = "北京" $Cities[] = "<B>天津</B>"; //等同于$Cities[1] = "天津" $Cities[] = "<B>上海</B>"; //等同于$Cities[2] = "上海" $Cities[] = "<B>深圳</B>"; //等同于$Cities[3] = "深圳" /* ** 统计元素个数 */ $indexLimit = count($Cities); //把数组中元素的个数赋给$indexLimit /* ** 打印所有数组 */ for($index=0; $index < $indexLimit; $index++) { print("第 $index 个城市是 $Cities[$index]。 <BR>\n"); } ?>
时间: 2024-10-12 07:39:28