我想获得这三种动物的所有名字,那就是梅德尔,费利克斯和丹佛。这些数据最初来自mysql数据库,我正在创建一个函数来显示所有动物的名字。
var_dump($ tab)
array (size=3)
0 =>
array (size=8)
'id' => string '1' (length=1)
0 => string '1' (length=1)
'name' => string 'Médor' (length=6)
1 => string 'Médor' (length=6)
'species' => string 'chien' (length=5)
2 => string 'chien' (length=5)
'age' => string '4' (length=1)
3 => string '4' (length=1)
1 =>
array (size=8)
'id' => string '2' (length=1)
0 => string '2' (length=1)
'name' => string 'Félix' (length=6)
1 => string 'Félix' (length=6)
'species' => string 'chat' (length=4)
2 => string 'chat' (length=4)
'age' => string '97' (length=2)
3 => string '97' (length=2)
2 =>
array (size=8)
'id' => string '3' (length=1)
0 => string '3' (length=1)
'name' => string 'Denver' (length=6)
1 => string 'Denver' (length=6)
'species' => string 'dinosaure' (length=9)
2 => string 'dinosaure' (length=9)
'age' => string '65000000' (length=8)
3 => string '65000000' (length=8)
我尝试了这个,但是它以第一个数组而不是第二个数组的索引开头
foreach($tab as $k => $val){
$tab[$k]["name"];
}
}