foreach()是一个用来遍历数组中数据的最简单有效的方法。
#example1:
<?php
$colors= array('red','blue','green','yellow');
foreach ($colorsas$color){
echo "Do you like $color? <br />";
}
?>
显示结果:
Do you like red?
Do you like blue?
Do you like green?
Do you like yellow?