Find Alexa Rank Of a Website Using PHP

Alexa rank is a online analytics service that continuously analyzing a website and gives your statistics. In this tutorial we are showing how to find Alexa rank of a given URL in PHP. This will help you to create a widget in your website to find the Alexa rank of a particular website.

First of all you have to create a PHP script. In this example I mixed both html & PHP in one single file for simplycity and understanding.

From this code you can see we are using simplexml_load_file to load the alexa data url and we passed the input website url along with the data url. This alexa data URL will return the data array in mix of object and array format.

You can filter the variable and print the relevant detials. In this I am displaying the Global rank of the website and country rank as well.

Demo

 

Editorial Staff
 

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.