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