Blogger Information
Blog 23
fans 0
comment 3
visits 15315
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php第三次作业--php第九期线上班
木易
Original
757 people have browsed it

1. 创建数组

//空数组
$arr= array();
var_dump($arr);
$arr1 = [];
var_dump($arr1);
echo '<hr>';

2. 关联数组、索引数组

//创建索引数组
$arr2 =array(
    '木易',
    '21岁'
);
var_dump($arr2);
echo '<br>';
$arr3 = [
    'abc',
    '123'
];
var_dump($arr3);
echo '<hr>';
//创建关联数组
$arr4 = array(
    'ouyangke'=> '欧阳克',
    'muyi' => '木易'
);
print_r($arr4);
echo '<br>';
$arr5 =[
    'ouyangke'=> '欧阳克',
    'muyi' => '木易'
];
print_r($arr5);
echo '<hr>';

3. 访问数组的数据

//访问数组的数据
$arr6 =array(
    '湖里区',
    '思明区',
    '集美区'
);
echo $arr6[0];
echo $arr6[1];
echo $arr6[2];
echo '<br>';
$arr7 = [
    'ouyangke'=> '欧阳克',
    'huangrong'=> '黄蓉',
    'guojing'=> '郭靖'
];
echo $arr7['ouyangke'];
echo $arr7['huangrong'];
echo $arr7['guojing'];
echo '<hr>';

4. 二维数组、三维数组

//创建二维数组
$arr8 = array(
    array(
        'name'=> '木易',
        'age'=> '21',
        'job'=> 'student'
    )
);
var_dump($arr8);
echo '<hr>';
//创建三维数组
$arr9 =array(
    array(
        'name'=> '木易',
        'age' => '21',
        'job' => [
            'html',
            'css',
            'php'
        ]
    )
);
var_dump($arr9);
echo '<hr>';

5. 二维数组循环,三维数组循环

//二维数组循环
$arr10 = [
    [
        'name'=> '木易',
        'age' => '21',
        'job' => 'student'
    ]
];
foreach($arr10 as $k=>$v){
    print_r($v);
    echo '<hr>';
}
//三维数组循环
$arr11 =[
    [
        'name'=> '木易',
        'age'=> '21',
        'job'=> 'student',
        'jineng' =>[
            'html',
            'css',
            'php'
        ]
    ]
];
foreach($arr11 as $k=>$v){
    print_r($v);
    echo '<hr>';
}

JTJQG%M[B{~S6L[)`M`KT)1.png

手写作业:

F8C7429DD63EE4739C2364DE17CB8C4D.jpg


Correcting teacher:查无此人查无此人

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