Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
Ad Blocking Detected
Please consider disabling your ad blocker for our website.
We rely on these ads to be able to run our website.
You can of course support us in other ways (see Support Us).
[Solved] PHP: Simple PHP script to retrieve the Alexa Ranking of your website
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter
August 18, 2015 3:14 AM
Below my simple PHP code to retrieve the Alexa page ranking of a given website ...
// Function: GetAlexaRank(websiteURL)
// Returns Alexa ranking or 0 (zero)
// Examples:
// echo GetAlexaRank(get_bloginfo('name')); // for Wordpress users
// echo GetAlexaRank('www.mywebsite.nl'); // for plain HTML or other CMS systems
funcion GetAlexaRank($url)
{
$xml = simplexml_load_file("http://data.alexa.com/data?cli=10&url=".$url);
if(isset($xml->SD->POPULARITY)) { $alexa = $xml->SD->POPULARITY->attributes()->TEXT; } else { $alexa=0; }
$alexa = echo number_format(floatval($alexa),0); // optional, for thousands
return $alexa;
}
Ad Blocking Detected
Please consider disabling your ad blocker for our website.
We rely on these ads to be able to run our website.
You can of course support us in other ways (see Support Us).