Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:01:05+00:00 2026-06-06T16:01:05+00:00

I have this code right here, where the $friends variable is an array with

  • 0

I have this code right here, where the $friends variable is an array with an output like this:

{
  "id": "1149862205",
  "name": "name",
  "first_name": "first_name",
  "last_name": "last_name",
  "link": "https://www.facebook.com/username",
  "username": "username",
  "birthday": "07/12/1990",
  "hometown": {
    "id": "108618265828550",
    "name": "name"
  }, 

while $fbfriendlikes variable is generated by the id of $friends and has this structure :

{
  "data": [
    {
      "name": "Penelope-ns-test",
      "category": "Community",
      "id": "187099821418102",
      "created_time": "2012-06-14T15:00:59+0000"
    },

Now, I need to print all $friends ids which like a specific id in $fbfriendlikes
My code goes like this:

$friends = $facebook->api('/me/friends');
if (!empty($friends['data'])) {
    $size = variable_get('facebook_graph_pic_size_nodes','square');
    $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
    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));

        if ($fbfriendlikes["id"] != 184759054887922) {
            $return .= '<div class="fimage">'.$image.'</div>';
            $link = '<a href="'.$protocol . '://www.facebook.com/profile.php?id='.$fbid.'" target="_blank">'.$fbname.'</a>';    
            $return .= '<div class="flink">'.$link.'</div>';
            break;
        }
    }
}

I know I have to do a foreach loop in $fbfriendslikes but I can’t seem to make it work.
Can you please give me an advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:01:07+00:00Added an answer on June 6, 2026 at 4:01 pm

    You need to check inside you loop to get the ones that don’t like.

    $return = '';
    $friends = $facebook->api('/me/friends');
    if (!empty($friends['data'])) {
        $size = variable_get('facebook_graph_pic_size_nodes','square');
        $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
        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));
    
            foreach($fbfriendlikes['data'] as $like) {
                $likes = false; // set var to check for like
                if($like['id'] == '184759054887922') { // check if they liked it
                    $likes = true; // set var to true because they liked it
                }
                if (!$likes) { // test var to see if false (they did not like)
                    // print this if they did NOT like it, otherwise do nothing
                    $return .= '<div class="fimage">'.$image.'</div>';
                    $link = '<a href="'.$protocol . '://www.facebook.com/profile.php?id='.$fbid.'" target="_blank">'.$fbname.'</a>';    
                    $return .= '<div class="flink">'.$link.'</div>';
                }
            }// go on to next in loop
    
        }
        echo $return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code right here: <select name=group> <option value=>Choose a group....</option> <?php foreach($groups
I have this code right here: // get host name from URL preg_match('@^(?:http://)?([^/]+)@i', http://www.joomla.subdomain.php.net/index.html,
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
I have a problem with this code right here: - (void)fetchedData:(NSData *)responseData { //parse
Right now, I have this code where $obj_arr maybe contain array and an object.
I have this piece of code right here , I really don't get it
I have this code right here: $('#add_club_button').click(function(){ $('#add_club_button_ajax').show(); $.post('<?php echo base_url()?>addClub/save',$('#add_club_form').serialize(),function(data){ if(data == 'OK'){
I have this HTML code right here.. <ul> <li><a href=# id=0>Services</a></li> <li><a href=# id=1>Portfolio</a></li>
I have this code right here. I have two problems though: In the receive
I have this code right now to get the row value from jquery grid..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.