php中實現循環遍歷的方法
1.使用each()函數實現循環遍歷
$url=array('張三 => '26','李四' => '36',
'王五' => '41'
);
while(list($a,$b)=each($url))
echo "$a=$b <br/>";
2.使用list()函數實現循環遍歷
$info = array('coffee','brown','caffeine');list($drink,$color,$power) = $info;
list($drink,,$power) = $info;
list( , ,$power) = $info;
3.使用while循環實現循環遍歷
$contact = array("張三" => "26",
"李四" => "36",
"王五" => "41",
);
echo '姓名';
while(list($key,$value) = each($contact)){
echo "<dd>$key : $value</dd>";
}
echo '</dl>';