+function api_best_nickname(&$contacts) {
+ $best_contact = array();
+
+ foreach ($contacts AS $contact)
+ if ($contact["network"] == "") {
+ $contact["network"] = "dfrn";
+ $best_contact = array($contact);
+ }
+
+ if (sizeof($best_contact) == 0)
+ foreach ($contacts AS $contact)
+ if ($contact["network"] == "dfrn")
+ $best_contact = array($contact);
+
+ if (sizeof($best_contact) == 0)
+ foreach ($contacts AS $contact)
+ if ($contact["network"] == "dspr")
+ $best_contact = array($contact);
+
+ if (sizeof($best_contact) == 0)
+ foreach ($contacts AS $contact)
+ if ($contact["network"] == "stat")
+ $best_contact = array($contact);
+
+ if (sizeof($best_contact) == 0)
+ foreach ($contacts AS $contact)
+ if ($contact["network"] == "pump")
+ $best_contact = array($contact);
+
+ if (sizeof($best_contact) == 0)
+ foreach ($contacts AS $contact)
+ if ($contact["network"] == "twit")
+ $best_contact = array($contact);
+
+ if (sizeof($best_contact) == 1)
+ $contacts = $best_contact;
+ else
+ $contacts = array($contacts[0]);
+}
+