尝试从数组中获取值并且它永远不会工作。我试图获得“Image_id”的值。我的循环如下:
foreach($gallery as $gimage) {
var_dump($gimage);
echo $gimage["Image_id"];
}
$ gallery的价值是:
Array(10) { [0]=> Array(2) { ["Image_id"]=> String(16) "I00000KPOFjox2AQ" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [1]=> Array(2) { ["Image_id"]=> String(16) "I00008BG9UDA9DeI" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [2]=> Array(2) { ["Image_id"]=> String(16) "I0000bpb88hlOpt8" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [3]=> Array(2) { ["Image_id"]=> String(16) "I0000vE8GZ8p_d5E" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [4]=> Array(2) { ["Image_id"]=> String(16) "I0000xDm267iNEKw" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [5]=> Array(2) { ["Image_id"]=> String(16) "I00004DMdHWsflCA" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [6]=> Array(2) { ["Image_id"]=> String(16) "I0000zoAFd_.Ywgo" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [7]=> Array(2) { ["Image_id"]=> String(16) "I00003TmAVNDJ7pE" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [8]=> Array(2) { ["Image_id"]=> String(16) "I0000kf4wIww90l0" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } [9]=> Array(2) { ["Image_id"]=> String(16) "I0000XbVhViGQiyk" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" } }
当我得到var_dump($ gimage)时,我得到了:
Array(2) { ["Image_id"]=> String(16) "I00000KPOFjox2AQ" ["Gallery_id"]=> String(16) "G0000bLsNtDO2rtg" }
但这总是失败:
echo $gimage["Image_id"];
我试过了
echo $gimage[0]["Image_id"];
echo $gimage[0];
答案 0 :(得分:0)
试试这个应该有效
var_dump($gimage[])