Posted By

serialk89 on 07/22/11


Tagged

sort api facebook Friend


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

guillermoj88gmailcom


Ordenar Alfabéticamente los amigos de facebook en app


 / Published in: PHP
 

Ordena alfabéticamente el array $friends['data'] obtenido con la api de facebook.

  1. //FUNCION QUE ORDENA
  2. function sortBySubkey(&$array, $subkey, $sortType = SORT_ASC) {
  3. foreach ($array as $subarray) {
  4. $keys[] = $subarray[$subkey];
  5. }
  6. array_multisort($keys, $sortType, $array);
  7. }
  8. //VARIABLE QUE RESCATA A LOS AMIGOS (LOS CAMPOS QUE SE ENCUENTRAN EN ESTE ARRAY SON ID Y NAME)
  9. $fls = $friends['data'];
  10.  
  11. //ORDENO el array $fls
  12. sortBySubkey($fls, 'name');

Report this snippet  

You need to login to post a comment.