Blogger Information
Blog 6
fans 0
comment 0
visits 3897
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第8期0917作业数组联系
宏利的博客
Original
780 people have browsed it

实例

<?php
header("Content-type: text/html; charset=utf-8");
// 定义数组
$a =[];
$b=array();
//关联数组
echo'<pre>';
$c =["name"=>"小虫子","sex"=>"男","age"=>12];
print_r($c);
echo '<hr>';
//索引数组
$d=["小虫子","男",18];
print_r($d);
echo '<hr>';
// 二位数组
$f= [["name"=>"小虫子","sex"=>"男","age"=>12],["name"=>"大虫子","sex"=>"男","age"=>15]];
print_r($f);
echo '<hr>';
// 循环二维数组
echo '<h1>循环二维数组</h1><br>';
foreach($f as $ff)
{
    foreach($ff as $fff)
    {
        print_r($fff);
        echo '<hr>';
    }
}
$f= [["name"=>"小虫子","sex"=>"男","age"=>12,"媳妇"=>["小花","小婷","小倩"]],["name"=>"大虫子","sex"=>"男","age"=>15,"媳妇"=>["小花","小婷","小倩"]]];
echo '<h1>循环三维数组</h1><br>';
foreach($f as $ff)
{
    echo "姓名:{$ff['name']} <br>";
    foreach($ff as $key=>$fff)
    {

        if($key=="媳妇")
        {
            foreach($fff as $key2=>$ffff)
            {
                $key3 = $key2+1;
                echo "<strong style=\"color:red;font-size:2rem;\">媳妇{$key3}:{$ffff} <br></strong>";
            }
        }
    }
    echo '<hr>';
}

运行实例 »

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


Correction status:qualified

Teacher's comments:完成的不错,还没教你就会了。
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