PHP : Problem with Arrays

isogramma

New Member
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:\[code\]<?php $friends = $facebook->api_client->friends_getAppUsers();?>\[/code\]$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:\[code\]<?phpforeach( $friends as $friend ){$fscores["$friend"] = get_user_bestscore($friend);}?>\[/code\]get_user_bestscore($friend); Function get the score from my DB.I sort the array to display friends sorted by score:\[code\]<?php sort($fscores); ?>\[/code\]In final step to dispaly the $fscores array to show friends names from ID, and Score I use:\[code\]<?phpforeach( $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>';}?>\[/code\]the $score var display the score stored from DB to array correctly, but $fid (Facebook Friend ID) display ex: 0I used print_r to know $scores array content i found :Array ( [0] => 5.87 )and in the first $friends array I found:\[code\]Array ( [0] => 100000625691889 )\[/code\]What I want to get is:\[code\]Array ( [100000625691889 ] => 5.87)\[/code\]Any solution please,Thanks in advance.
 
Back
Top