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
rofile-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 well, 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.
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
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 well, 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.