Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:为什么我只比欧阳老师大一岁?
写得不错
<?php
$arr1 = array(
'欧阳克','18岁','php讲师'
);
$arr2= [
'朱老师','19岁','php讲师'
];
print_r($arr1);
echo "<br>";
print_r($arr2);
?>
<?php
索引数组的键值是数字
$arr1 = array(
000=>'欧阳克',
111=>'18岁',
222=>'php讲师'
);
$arr2= [
000=>'朱老师',
111=>'19岁',
222=>'php讲师'
];
print_r($arr1);
echo "<br>";
print_r($arr2);
echo "<br>";
//关联数组的键值是字符串
$arr3 = array(
'name'=>'欧阳克',
'age'=>'18岁',
'job'=>'php讲师'
);
$arr4= [
'姓名'=>'朱老师',
'年龄'=>'19岁',
'职业'=>'php讲师'
];
print_r($arr3);
echo "<br>";
print_r($arr4);
echo "<br>";
?>
<?php
//访问数组里的元素
$arr1 = array(
'name'=>'欧阳克',
'age'=>'18岁',
'job'=>'php讲师'
);
$arr2= [
'姓名'=>'朱老师',
'年龄'=>'19岁',
'职业'=>'php讲师'
];
print_r($arr1['name']);
print_r($arr2['年龄']);
?>
<?PHP
$arr3 = [
[
'name'=>'欧阳克',
'age'=>'18岁',
'job'=>'php讲师'
],
[
'name'=>'朱老师',
'age'=>'19岁',
'job'=>'php讲师'
]
];
print_r($arr3[0]);
echo "<br>";
print_r($arr3[1]);
//三维数组
$arr4 = [
[
'name'=>'朱老师',
'age'=>'19岁',
'job'=>'php讲师',
'course'=>['html','css']
]
];
print_r($arr4);
?>
//二维数组循环
$arr3 = [
[
'name'=>'欧阳克',
'age'=>'18岁',
'job'=>'php讲师'
],
[
'name'=>'朱老师',
'age'=>'19岁',
'job'=>'php讲师'
]
];
foreach ($arr3 as $v){
print_r($v['name']);
echo "<br>";
}
//三维数组循环
$arr4 = [
[
'name'=>'朱老师',
'age'=>'19岁',
'job'=>'php讲师',
'course'=>['html','css']
],
[
'name'=>'欧阳克',
'age'=>'18岁',
'job'=>'php讲师',
'course'=>['php','js']
]
];
foreach($arr4 as $v){
echo '姓名:'.$v['name'].'--';
echo '年龄:'.$v['age'].'--';
echo '职业:'.$v['job'].'--';
echo '技能:';
foreach($v['course'] as $vv){
echo $vv.'-';
}
echo '<hr>';
}
?>