好吧,所以數組是我的弱點,我正在爲此付出努力。這可能也很簡單。基本上,我有一個數組是與foreach和多維數組相混淆 - PHP
代碼:
Array
(
[data] => Array
(
[0] => Array
(
[name] => getalbum
[fql_result_set] => Array
(
[0] => Array
(
[aid] => 187046464639937_101906
[name] => photo tab
[cover_pid] => 187046464639937_1661168
)
[1] => Array
(
[aid] => 187046464639937_99627
[name] => Cover Photos
[cover_pid] => 187046464639937_1661054
)
)
)
[1] => Array
(
[name] => getcover
[fql_result_set] => Array
(
[0] => Array
(
[src] => http://photos-g.ak.fbcdn.net/hphotos-ak-prn1/526499_403098366368078_187046464639937_1661168_217706037_s.jpg
)
[1] => Array
(
[src] => http://photos-b.ak.fbcdn.net/hphotos-ak-ash3/562470_403049039706344_187046464639937_1661054_361917190_s.jpg
)
)
)
)
)
我使用一個foreach使用 PHP代碼來調用數組:
foreach($fql_query_obj['data'] as $albums){
foreach($albums['fql_result_set'] as $album){
//print_r($album);
if ( ($album['name'] != "Wall Photos")
&& ($album['name'] != "Cover Photos")
&& ($album['name'] != "photo tab"))
{
echo $album['name'].' :: '.$album['aid'];
echo '<img src="'.$album['src'].'" /><br />';
}
}
}
現在看來要經過getalbum數組然後getcover。我該怎麼做才能將它們合併在一起?
您能提供您期望的輸出樣本嗎?最後你的問題還不清楚。 「將它們合併在一起」是什麼意思? – 2012-04-09 22:41:54