Hi, I'm a php newbie, and I'm creating a Facebook application for my flash game. In the main page of the application, I want to print the current user friends sorted by score.
I get first user friends using my application with this API function:
<?php $friends = $facebook->api_client->friends_getAppUsers();?>
$friends is an Array with all user friends ID's, every ID is a bigint.
after that I create another array to store in Friends ID's + Scores:
<?php
foreach( $friends as $friend )
{
$fscores["$friend"] = get_user_bestscore($friend);
}
?>
get_user_bestscore($friend); Function get the score from my DB.
I sort the array to display friends sorted by score:
<?php sort($fscores); ?>
In final step to dispaly the $fscores array to show friends names from ID, and Score I use:
<?php
foreach( $fscores as $fid => $score )
{
echo '<P>';
echo '<fb:profile-pic uid="'.$fid.'" linked="true" /><br>';
echo '<b># '.$counter++.'</b>';
echo '<b>- <fb:name uid="'.$fid.'" useyou="false"/></b><br>';
echo '<b>Score : '.$score.'</b>';
echo '</P>';
}
?>
the $score var display the score stored from DB to array correctly, but $fid (Facebook Friend ID) display ex: 0
I used print_r to know $scores array content i found : Array ( [0] => 5.87 )
and in the first $friends array I found:
Array ( [0] => 100000625691889 )
What I want to get is:
Array ( [100000625691889 ] => 5.87)
Any solution please,
Thanks in advance.