Click here to Skip to main content
13,253,863 members (64,226 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 15 Nov 2010

Alexa ranking using php script

, 15 Nov 2010
Rate this:
Please Sign up or sign in to vote.
if you want to check the your website ranking as per alexa so you can use the following code in your php projects.
“” this file will return the xml format output. Using the XML output or reading xml file we can easily fetch the our or any website ranking.
Use the following function for getting the alexa website ranking.

function AlexaRank( $url )
preg_match( '#<POPULARITY URL="(.*?)" TEXT="([0-9]+){1,}"/>#si', file_get_contents('' . $url), $p );
return ( $p[2] ) ? number_format( intval($p[2]) ):0;
echo " Rank as per ";
echo AlexaRank('');

if you want to check the multiple website ranking in one shot than use the following PHP code.

$domains = array( '', '', '', '' );
foreach ( $domains as $domain )
echo $domain, ' - ', AlexaRank( $domain ), '<br />', PHP_EOL;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Estonia Estonia
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...


Comments and Discussions

GeneralPreg_match return Pin
philippe alarcon22-Nov-10 6:11
memberphilippe alarcon22-Nov-10 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 15 Nov 2010
Article Copyright 2010 by marigoula
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid