Blogger Information
Blog 13
fans 0
comment 0
visits 8819
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1113作业
文永
Original
606 people have browsed it

实例

<?php

//$arr =10;
//$arr ='apple';
//创建数组
$arr1 = array();
var_dump( $arr1);
echo '<hr>';
$arr2 = [];
var_dump($arr2);
echo '<hr>';

//索引数组
$arr = [
    10,
    11,
    '欧阳克',
    '朱老师',
    12.9,
    null
];
//打印数组
print_r( $arr );
echo '<hr>';
//关联数组
$arr2 = [
    '10001' => '朝阳区',
    '10002' => '海淀区',
    '10003' => '房山区',
    '10004' =>  '大兴区',
];
print_r( $arr2 );
echo '<hr>';

//数组的输出
//方括号里面写的是key 输出的是值
print_r( $arr2 ['10002']);
echo '<hr>';
echo $arr2[ '10003' ];


echo '<hr>';

//多维数组

/*$arr3 = [
    [
        'name' => '欧阳克',
        'age' => "18岁",
        'job' => '讲师',
        'jineng' => [
            'php',
            'html',
            'js',
        ]
    ],
    [   'name' => '西门',
        'age' => "17岁",
        'job' => '讲师',
        'jineng' => [
            'php',
            'html',
            'js',
        ]
        ],
    [
        'name' => '朱老师',
        'age' => "120岁",
        'job' => '讲师',
        'jineng' => [
            'php',
            'html',
            'js',
        ]
    ],
];

print_r( $arr3[1]['name']);
echo '<hr>';

print_r($arr3[1]['jineng'][0]);


echo '<hr>';
*/

//php数组循环

//二维数组循环

$arr3 = [
    [
        'name' => '欧阳克',
        'age' => "18岁",
        'job' => '讲师',
        'jineng' => [
            'php',
            'html',
            'js',
        ]
    ],
    [   'name' => '西门',
        'age' => "17岁",
        'job' => '讲师',
        'jineng' => [
            'php',
            'html',
            'js',
        ]
    ],
    [
        'name' => '朱老师',
        'age' => "120岁",
        'job' => '讲师',
        'jineng' => [
            'php',
            'html',
            'js',
        ]
    ],
];

foreach ( $arr3 as $v ){
    //print_r($v['name'] );
    echo '<hr>';
    echo '姓名:' .$v['name'] .'---';
    echo '年龄:' .$v['age'] .'---';
    echo '职业:' .$v['job'] .'---';
    echo '技能:';
    foreach ($v ['jineng'] as $vv)
        echo $vv.'-';
    echo '<hr>';
}

image.png

image.png

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!