Example #1
0
             // This part was a little tricky
             // While $link->id seems like it might be a string, it's actually a SimpleXMLElement (should've print_r from the beginning)
             // You can't use an object as an array index
             // Putting "". in front of it makes $id a string
             // Simple when you think about it. Annoying when it just gives you some weird error
             $id = "" . $link->id;
             if (isset($link->comments) && $link->comments > -1) {
                 $updates[$id]["comment"] = $link->comments;
                 if ($link->both == true || $link->both == "true" || $link->both == 1) {
                     $updates[$id]["link"] = 1;
                 }
             } else {
                 $updates[$id]["link"] = 1;
             }
         }
         insertLinks($updates, $developer, $authinfo["userid"], $authinfo["device"]);
         xsuccess(count($updates) . " links updated", "xml");
     } else {
         $links = array();
         $i = 0;
         foreach ($xml->links->link as $link) {
             $links[$i++] = "" . $link->id;
             // convert simplexml to string. not that important here though
         }
         $result = readLinks($links, $authinfo["userid"], "xml");
         echo $result;
         die;
     }
 } catch (Exception $e) {
     xerror("xml error", "xml");
 }
function niceQuestionFormat($text, $searchWords = '')
{
    $result = insertLinks($text);
    $result = highlightWords($result, $searchWords);
    return $result;
}