Return to Snippet

Revision: 67774
at October 29, 2014 08:50 by codingforever99

Initial Code
function Get_Alexa_Rank($domain)
    $alexa = "";
    $request_url =  sprintf($alexa, urlencode($domain));
    $xml = simplexml_load_file($request_url);
    if (!isset($xml->SD[1])) {
        return FALSE;
    $nodeAttributes = $xml->SD[1]->POPULARITY->attributes();
    $text = (int) $nodeAttributes['TEXT'];
    return $text;

echo "The alexa rank for Google is :". Get_Alexa_Rank('') ."<BR>";
echo "The alexa rank for blogger is :". Get_Alexa_Rank('') ."<BR>";

Initial URL

Initial Description
Getting alexa rank is simple, a data link provide by alexa only needs the domain name and then it return xml data including the rank we want, so I make a php function to do this task.

Initial Title
Get alexa rank using php

Initial Tags

Initial Language