Blogger Information
Blog 25
fans 2
comment 0
visits 18705
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP教学-php数组循环
果莫个人博客
Original
638 people have browsed it

<?php
//创建数组
$arr1 =10;
$arr2 ='ouyang';


$arr =array( );

var_dump( $arr2);


//创建索引数组

$arr =10;
$arr =array(
   10,
   11,
   '欧阳克',
   '朱老师',
   19.99,
   null
);
print_r($arr);
echo '<hr>';
$arr=[
   10,11,'欧阳克'
];
print_r($arr);
echo '<hr>';

//关联数组
$arr =[
 'hefei'=>'合肥',
 'luyang'=>'庐阳区',
 'zhengwu'=>'政务区'
];
print_r($arr);
echo '<hr>';
print_r($arr['hefei']);
echo '<hr>';
//访问数组的数据
echo $arr['hefei'];
echo '<hr>';
echo $arr['luyang'];

echo '<hr>';
//二维数组
$arr=[
   'hefei'=>'合肥',
   'luyang'=>'庐阳区',
   'zhengwu'=>'政务区',
   'php'=>[
       'name1'=>'欧阳克',
       'name2'=>'朱老师'
   ]
];

echo $arr ['php']['name1'];
echo '<hr>';

//二维数组循环
foreach($arr as $a){
   echo $a;
}




//三维数组
$arr=[
   'hefei'=>'合肥',
   'luyang'=>'庐阳区',
   'zhengwu'=>'政务区',
   'php'=>[
       'name1'=>'欧阳克',
       'name2'=>'朱老师',
       'name3'=>[
             'sw1'=> '三维1',
             'sw2'=>'三维2',
             'sw3'=>'三维3'

       ]
   ]
];
echo $arr[php][name3][sw2];
echo '<hr>';



//三维数组循环
foreach($arr as $a){
   foreach($a as $a2){
       foreach($a2 as $a3){
           echo $a3;
       }            
   }
}





2.jpg1.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