Blogger Information
Blog 8
fans 0
comment 0
visits 4753
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php数组练习2019年09月17日
zzc111的博客
Original
536 people have browsed it

实例

<?php


echo'<h3>一维数组</h3>';
$arr = ['php中文网', '你好!我的世界','好好学习'];

        echo'<h4>带KEY输出</h4>';
            print_r ($arr);
            echo'<br>';
        echo'<h4>带KEY和数据类型输出</h4>';
            var_dump($arr);
            echo'<hr>';
            echo $arr;
       

echo'<h3>关联数组</h3>';
    $diming =[
        'hainan'=>'海南',
        'henan'=>'河南',
        'hefei'=>'合肥'
    ];

    print_r ($diming);
        echo'<hr>';

echo'<h3>二维数组</h3>';
    $chengshi=[
        ['sheng'=>'海南',
        'cheng'=>'海口'],
        ['sheng'=>'河南',
        'cheng'=>'郑州'],
        ['sheng'=>'安徽',
        'cheng'=>'合肥']
    ];

    print_r($chengshi);

    echo'<hr>';


echo'<h3>三维数组</h3>';
$chengshi=[
    ['sheng'=>'海南',
    'cheng'=>'海口',['bianhao'=>'1']],
    ['sheng'=>'河南',
    'cheng'=>'郑州',['bianhao'=>'2']],
    ['sheng'=>'安徽',
    'cheng'=>'合肥',['bianhao'=>'3']]
];

print_r($chengshi);

echo'<hr>';
echo'<h3>三维数组循环</h3>';

foreach($chengshi as $shuchu){
    print_r($shuchu) ;
 
    echo'<hr>';
}
    ?>

运行实例 »

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

老师 你好 !

为什么我用 echo 总报错呢?百度看的不太明白!

QQ截图20190918010754.png

Correction status:qualified

Teacher's comments:完成的不错。错误的地方:echo不能输出 数组。 讲了很多遍了,多看视频
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