Blogger Information
Blog 63
fans 1
comment 0
visits 76101
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
创建一个二维数组,进行遍历
桃儿的博客
Original
782 people have browsed it

 创建一个二维数组,进行遍历

实例

<?php
//一维数组
$fruits=['苹果','香蕉','桃儿','梨','草莓','西瓜'];
//二维数组
$foods=[
    ['苹果','香蕉','桃儿','梨','草莓','西瓜'],
    ['豆角','茄子','辣椒','西红柿','白菜','萝卜'],
    ['馒头','米饭','包子','烧饼','小米粥']
];
//遍历一维数组
foreach ($fruits as $fruit){
    echo $fruit;
    echo '<br>';
}
echo '<hr>';
//遍历二维数组
foreach ($foods as $food){
    foreach ($food as $value){
        echo $value;
        echo '<br>';
    }
}

运行实例 »

点击 "运行实例" 按钮查看在线实例



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post