Blogger Information
Blog 32
fans 1
comment 0
visits 23222
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php数组-PHP培训第九期线上班
淡月
Original
538 people have browsed it

实例

<?php


$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' => '长宁区',
    '10005' => '浦东新区',
];
print_r( $arr2 );
echo '<hr>';

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


echo '<hr>';

//多维数组



$arr3 = [
    [
        'name' => '淡月酱',
        'age' => "22岁",
        'job' => '学生',
        'jineng' => [
            '吃饭',
            '睡觉',
            '写代码',
        ]
    ],
    [   'name' => '溪上花间',
        'age' => "22岁",
        'job' => '学生',
        'jineng' => [
            '吃饭',
            '睡觉',
            '打豆豆',
        ]
    ],
    [
        'name' => '小小挽歌',
        'age' => "21岁",
        'job' => '社畜',
        'jineng' => [
            '吃饭',
            '睡觉',
            '上班',
        ]
    ],
];

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>';
}




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