萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php遍歷輸出數組的方法

php遍歷輸出數組的方法

php教程遍歷輸出數組的方法

<html>
<head>
<title>Foreach Demo</title>
</head>
<body>
<?

$list = array("A", "B", "C", "D", "E");

print "<ul>n";
foreach ($list as $value){
  print " <li>$value</li>n";
} // end foreach
print "</ul>n";

?>
</body>
</html>

實例二

<?
$letters[0] = 'A';
$letters[1] = 'B';
$letters[3] = 'D';
$letters[2] = 'C';

foreach ($letters as $letter) {
    print $letter;
}
?>
 

copyright © 萬盛學電腦網 all rights reserved