Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP : Problem with Arrays
    primarykey
    data
    text
    <p>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.</p> <p>I get first user friends using my application with this API function:</p> <pre><code>&lt;?php $friends = $facebook-&gt;api_client-&gt;friends_getAppUsers();?&gt; </code></pre> <p>$friends is an Array with all user friends ID's, every ID is a bigint.</p> <p>after that I create another array to store in Friends ID's + Scores:</p> <pre><code>&lt;?php foreach( $friends as $friend ) { $fscores["$friend"] = get_user_bestscore($friend); } ?&gt; </code></pre> <p>get_user_bestscore($friend); Function get the score from my DB.</p> <p>I sort the array to display friends sorted by score:</p> <pre><code>&lt;?php sort($fscores); ?&gt; </code></pre> <p>In final step to dispaly the $fscores array to show friends names from ID, and Score I use:</p> <pre><code>&lt;?php foreach( $fscores as $fid =&gt; $score ) { echo '&lt;P&gt;'; echo '&lt;fb:profile-pic uid="'.$fid.'" linked="true" /&gt;&lt;br&gt;'; echo '&lt;b&gt;# '.$counter++.'&lt;/b&gt;'; echo '&lt;b&gt;- &lt;fb:name uid="'.$fid.'" useyou="false"/&gt;&lt;/b&gt;&lt;br&gt;'; echo '&lt;b&gt;Score : '.$score.'&lt;/b&gt;'; echo '&lt;/P&gt;'; } ?&gt; </code></pre> <p>the $score var display the score stored from DB to array correctly, but $fid (Facebook Friend ID) display ex: 0</p> <p>I used print_r to know $scores array content i found : Array ( [0] => 5.87 )</p> <p>and in the first $friends array I found: <code>Array ( [0] =&gt; 100000625691889 )</code></p> <p>What I want to get is: <code>Array ( [100000625691889 ] =&gt; 5.87)</code></p> <p>Any solution please,</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload