public function getPhotos($id_album){
$hisPhoto = '123';
$myPhoto = '456';
$herPhoto = '789';
$id_user = 1;
$photoTable = array
(
'hisPhoto' => $hisPhoto,
'myPhoto' => $myPhoto,
'herPhoto' => $herPhoto,
);
return array
(
'id_user' => $id_user,
'photos' => $photoTable
)
}
$photos = getPhotos($id_album);
我不知道如何在关联数组中使用关联数组。使用此函数访问我的照片(值"456"(的最简单方法是什么?
$photos
最终将具有以下结构:
Array
(
'id_user' => $id_user,
'photos' =>
Array
(
'hisPhoto' => $hisPhoto,
'myPhoto' => $myPhoto,
'herPhoto' => $herPhoto
)
)
所以你可以去:
echo $photos['photos']['myPhoto'];
如果您坚持数组的结构,您可以使用:
print_r($array);
查看结构