PHP - 访问多维数组值
2022-08-30 20:00:57
经过几个小时的混乱,出汗和拔掉头发,我仍然无法访问这些值。我想遍历数组的第一级,这对于基本的“foreach”循环来说非常简单,但我似乎无法到达第二个子数组上的“['fitability']”数组。我已经环顾四周,但似乎除了真正基本的数组教程之外,什么也得不到,这些教程似乎没有深入研究循环。
我正在尝试访问嵌套/子数组中的值,即“['Species_name']”。
我不想使用关联键,因为排序有点问题。
Array
(
[0] => Array
(
[id] => 1
[name] => Bradeley Hall Pool
[postcode] => CW1 5QN
[lat] => 53.10213
[lon] => -2.41069
[size] => 1.60
[pegs] => 21
[distance] => 26.6
)
[1] => Array
(
[id] => 2
[name] => Farm Pool
[postcode] => CW9 6JQ
[lat] => 53.320502
[lon] => -2.549049
[size] => 0.88
[pegs] => 8
[distance] => 15.4
[suitability] => Array
(
[0] => Array
(
[fk_water_id] => 2
[fk_species_id] => 4
[species_name] => Barbel
[species_rating] => 1
[record_id] => 1
[weight_kg] => 2.721554
[length_cm] => 40
[height_cm] => 30
)
)
)
)