Blogger Information
Blog 9
fans 0
comment 0
visits 5788
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php基础3-第九期线上班作业(补11.13)
张智平
Original
641 people have browsed it

实例

<?php
//创建数组
$arr1 = array();
$arr2 = [1,
    2,
    3,
];
echo $arr2[2];

echo '<hr>';
//关联数组、索引数组,访问数组数据
$wh=[
   'hs' => '洪山区',
   'wc' => '武昌区',
   'xz' => '新洲区',
   'ja' => '江岸区',
   'hp' => '黄陂区',
];
print_r($wh);
echo $wh['hs'];
echo $wh['wc'];
echo '<hr>';

$wh=[
    '洪山区',
    '武昌区',
    '新洲区',
    '江岸区',
    '黄陂区',
];
print_r($wh);
echo $wh[2];
echo '<hr>';


//二维数组、三维数组
$wh=[
    '洪山区' => ['关山街',
        '狮子山街',
        '和平街',],
    '武昌区',
    '新洲区',
    '江岸区',
    '黄陂区',
];
print_r($wh);
echo $wh['洪山区'][0];
echo '<hr>';


//二维数组循环,三维数组循环
$wh=[
    'hs' => '洪山区',
    'wc' => '武昌区',
    'xz' => '新洲区',
    'ja' => '江岸区',
    'hp' => '黄陂区',
];

foreach ($wh as $v){
    echo $v;
    echo '<hr>';

}


$wh3=[
    ['hs' => ['关山街',
        '狮子山街',
        '和平街']],
    ['wc' => ['武昌区']],
    ['xz' => ['新洲区']],
    ['ja' => ['江岸区']],
    ['hp' => ['黄陂区']],
];
foreach ( $wh3 as $qu ){
    foreach ( $qu['hs'] as $jiedao ){
//        print_r($jiedao);
    echo $jiedao;

    }

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