Possible Duplicate:
php loop through associative arrays
i have a variable which prints an array names $friends, the output of it is something like this:
{
"data": [
{
"name": "Penelope-ns-test",
"category": "Community",
"id": "187099821418102",
"created_time": "2012-06-14T15:00:59+0000"
},
{
"name": "Fabric",
"category": "Computers/technology",
"id": "194407767268061",
"created_time": "2012-06-07T07:24:03+0000"
},
etc...
I need to do a loop in order to get something like this : if friends[id] == 1203438484 {
}
else...
foreach($friends['data'] as $data){
$fbid = $data['id'];
$fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes');
$fbname = $data['name'];
$path = $protocol . '://graph.facebook.com/' . $fbid . '/picture?type=' . $size;
$image = theme('image', array('path' => $path, 'alt' => $fbname));
$return .= '<div class="fimage">'.$image.'</div>';
$link = '<a href="'.$protocol . '://www.facebook.com/profile.php?id='.$fbid.'" target="_blank">'.$fbname.'</a>';
foreach ($fbfriendlikes["data"] as $fbfriendlikes) {
if ($fbfriendlikes["id"] == 184759054887922) {
$return .= '<div class="flink">'.$link.'</div>';
break;
}
}
}
Can you help me with the code? Thanks!