欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

foreach遍历数组

程序员文章站 2022-04-24 14:38:27
...

无详细内容 无 ?php/* * foreach */ $fruits = array("lemon" , "orange" , "banana" , "apple");sort($fruits);$n = count($fruits);echo "Length of fruits is: ".$n."br/";foreach ($fruits as $key = $val) { echo "fruits[".$key."] = ".$val."br/";} ?

";

foreach ($fruits as $key => $val) {
    echo  "fruits[".$key."] = ".$val."
"; } ?>