Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
$str="helloword"
$int=250
$bool=true
$float=3.1415926
$stu = ['name' => 'Tim', 'stuNo' => 202201, 'mobile' => 18956785474];
$obj = new stdClass;
$a=NUll
$navs = ['id' => 1, 'name' => '前端相关'];
是一个一位维数组,使用[]访问其属性,例如访问上述例子中的name属性代码为$navs['name']
<?php
$players=[
['id'=>1,'name'=>'想你的春天','sex'=>'男'],
['id'=>2,'name'=>'想你的夏天','sex'=>'男'],
['id'=>3,'name'=>'想你的秋天','sex'=>'男'],
['id'=>4,'name'=>'想你的冬天','sex'=>'男'],
['id'=>5,'name'=>'想你的每一天','sex'=>'男'],
];
for($i=0;$i<count($players);$i++){
echo $players[$i]['id'];
echo $players[$i]['name'];
echo $players[$i]['sex'];
};
-以下代码使用foreach来遍历上述二维数组
foreach($players as $key=>$value){
foreach($value as $key2=>$value2){
echo $key2 . $value2;
};
};