I feel rather stupid for asking this, but how is it that this
foreach ($fbuser['feed']['data'] as $fbmsg){
var_dump($fbmsg['message']);
die;
produces the exact result I want, it shows me the contents of the array key ‘message’…
…while this throws an error stating that the key ‘message’ is undefined…
foreach ($fbuser['feed']['data'] as $fbmsg){
$r .= '<tr><td class="fb_td"><img src="https://graph.facebook.com/'.$fbmsg['from']['id'].'/picture" class="fb_img"></td><td>'.
' <i>'.$fbmsg['from']['name'].'</i><br>'.
$fbmsg['message'].'</td></tr>';
}
Here is the var_dump, clearly containing a [‘message’] key…
array(19) { ["id"]=> string(28) "167669502405_366091400140059" ["from"]=> array(3) { ["category"]=> string(21) "Professional services" ["name"]=> string(9) "Warp Nine" ["id"]=> string(12) "167669502405" } ["message"]=> string(47) "Nu finns Warp Nine's annons på pizzakartonger!" ["story"]=> string(40) "Warp Nine shared Annonspizza AB's photo." ["story_tags"]=> array(2) { [0]=> array(1) { [0]=> array(5) { ["id"]=> string(12) "167669502405" ["name"]=> string(9) "Warp Nine" ["offset"]=> int(0) ["length"]=> int(9) ["type"]=> string(4) "page" } } [17]=> array(1) { [0]=> array(5) { ["id"]=> string(15) "182446165166120" ["name"]=> string(14) "Annonspizza AB" ["offset"]=> int(17) ["length"]=> int(14) ["type"]=> string(4) "page" } } } ["picture"]=> string(83) "http://photos-d.ak.fbcdn.net/hphotos-ak-ash4/384287_370171156393619_242673100_s.jpg" ["link"]=> string(105) "http://www.facebook.com/photo.php?fbid=370171156393619&set=a.347118762032192.78549.182446165166120&type=1" ["name"]=> string(15) "Timeline Photos" ["caption"]=> string(88) "Vi har även något att läsa då vi äter pizzan. Såhär ser kartongen ut på insidan!" ["properties"]=> array(1) { [0]=> array(3) { ["name"]=> string(2) "By" ["text"]=> string(14) "Annonspizza AB" ["href"]=> string(71) "http://www.facebook.com/pages/Annonspizza-AB/182446165166120?ref=stream" } } ["icon"]=> string(59) "http://static.ak.fbcdn.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif" ["privacy"]=> array(1) { ["value"]=> string(0) "" } ["type"]=> string(5) "photo" ["status_type"]=> string(12) "shared_story" ["object_id"]=> string(15) "370171156393619" ["application"]=> array(2) { ["name"]=> string(6) "Photos" ["id"]=> string(10) "2305272732" } ["created_time"]=> string(24) "2012-10-04T21:05:55+0000" ["updated_time"]=> string(24) "2012-10-04T21:05:55+0000" ["comments"]=> array(1) { ["count"]=> int(0) } }
If you have three arrays inside of
$fbuser['feed']['data']and array1 has a message key but array2 and array3 do not then you will receive an error.Try: