Author Topic: Get Alexa Rank using Php  (Read 5903 times)


  • Administrator
  • VIP Member
  • *****
  • Posts: 1826
  • I want to show my performance at any where
    • View Profile
    • Higher Education
Get Alexa Rank using Php
« on: February 09, 2012, 09:32:01 AM »
Here is a simple PHP script to get the Alexa Rank of any website. This script can be used to display the Alexa Rank without any widget or plugin.

Some people tend to enter the Alexa Rank in About Us page, but since the rank keeps changing they got to update it often, I see some sites in Blogosphere where people hardly edit the Alexa Rank, such cases, this PHP script can dynamically generate the accurate present Alexa Rank

PHP Code for Alexa Rank

    $url = ‘’;
    $new_url = ‘’.$url;

    /* This will find the Global Alexa Rank */
    $start = strpos($contents, “<div class=”data up”>”) +119;
    $stop= strpos($contents,”<div class=”label”>Alexa Traffic Rank”);
    $result = substr($contents,$start,$stop-$start);
    echo “Global Alexa Rank for “.$url.” = “.$result;

moz screenshot Get Alexa Rank using Php
Download Alexa Rank PHP Script:
Acquire the knowledge and share the knowledge so that knowing,learning then sharing - all are the collection