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 7921055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:26:32+00:00 2026-06-03T16:26:32+00:00

AND THE DISPLAY FRIENDS FUNCTION MENTIONED IN THE NEXT FUNCTION function displayfriends($major, $friends) {

  • 0

AND THE DISPLAY FRIENDS FUNCTION MENTIONED IN THE NEXT FUNCTION

 function displayfriends($major, $friends) {
    // Whatever markup you want here
    // For example -- unordered list
if (count($friends) > 0) {
echo "<h2>Friends with $major major</h2>";
echo '<ul>';
foreach ($friends as $friend) {
    echo "<li>$friend</li>";
}
echo '</ul>';

}
}

THIS IS A TEST FUNCTION TO WORK WITH THE UI

 function getFriendsWithMajor($major) {
 $config = array(
 'appId' => '',
 'secret' => '',
 );
 $facebook = new Facebook($config);
 $user_id = $facebook->getUser();
 try {
 $fql    =   "select uid,name,education from user WHERE uid IN (select uid2 from friend where uid1=($user_id))";
 $param  =   array(
 'method'    => 'fql.query',
 'query'     => $fql,
 'callback'  => ''
 );
 $fqlResult   =   $facebook->api($param);
 } catch(Exception $o) {
    d($o);
 }

 $friends = $fqlResult;
 $friends_BA = array();

 foreach ($friends as $friend) {
     if (is_array($friend['education'])) {
         foreach ($friend['education'] as $school) {
             if (isset($school['concentration'])) {
                foreach ($school['concentration'] as $concentration) {
                    if (strpos(strtolower($concentration['name']), $major) !== false) {
                        $friends_BA[] = $friend['name'];
                        continue 3; // skip to the next friend
                    }
                }
             }
        }
    }
}
$this->displayfriends($major);

}

Here’s the output I’m getting:
Warning: Missing argument 2 for social::displayfriends(), called in /home/content/07/8316707/html/class.Social.php on line 234 and defined in /home/content/07/8316707/html/class.Social.php on line 183

Keep in mind, when I did $this->displayfriends($major, $friends) it only returned one result when it should have returned 15.

  • 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-03T16:26:35+00:00Added an answer on June 3, 2026 at 4:26 pm

    I think I understand what you’re looking for. You basically just need to understand php arrays, and how to use parameters with functions. print_r is a debugging tool that generates the output you see. For use of your array data, you should handle it directly. Simplest way is to foreach through it. I made a separate function for the display just to reinforce both concepts.

    function getFriendsWithMajor($major) {
         $config = array(
         'appId' => 'XXXXXXX',
         'secret' => 'XXXXXXXXXX',
         );
         $facebook = new Facebook($config);
         $user_id = $facebook->getUser();
         try {
         $fql    =   "select uid,name,education from user WHERE uid IN (select uid2 from friend where uid1=($user_id))";
         $param  =   array(
         'method'    => 'fql.query',
         'query'     => $fql,
         'callback'  => ''
         );
         $fqlResult   =   $facebook->api($param);
         } catch(Exception $o) {
            d($o);
         }
    
         $friends = $fqlResult;
         $friends_BA = array();
    
         foreach ($friends as $friend) {
             if (is_array($friend['education'])) {
                 foreach ($friend['education'] as $school) {
                     if (isset($school['concentration'])) {
                        foreach ($school['concentration'] as $concentration) {
                            if (strpos(strtolower($concentration['name']), $major) !== false) {
                                $friends_BA[] = $friend['name'];
                                continue 3; // skip to the next friend
                            }
                        }
                     }
                }
            }
        }
        displayfriends($major, $friends_BA);
    }
    

    Display function

    function displayfriends($major, $friends) {
            // Whatever markup you want here
            // For example -- unordered list
      if (count($friends) > 0) {
        echo "<h2>Friends with $major major</h2>";
        echo '<ul>';
        foreach ($friends as $friend) {
            echo "<li>$friend</li>";
        }
        echo '</ul>';
      }
    }
    

    Calling the functions:

    getFriendsWithMajor('**business**);
    getFriendsWithMajor('**marketing**);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a friends list type function that will display a user's friends
I have a page where I display a friends list from my website members.
I am trying to display a list of friends names ie: first_name and last_name.
does Display:none or jquery Hide function speed up my website, i mean i'm developing
Is it possible to display a view from another controller? Say for example I
How can I display only selected headers in DataGridView control? For example I have
<script type=text/javascript> var showGrid = function() { $(#Grid1).load('/friends/names/fried'); }; </script> <div> <%= Html.Trirand().JQGrid(Model.OrdersGrid, JqGrid1)%>
I have got the list of my friends and i can traverse through the
I need to display the names of my friends who approved my application request.
Alright friends of the WebDev community, I am just mucking around here and I

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.