There is nice wordpress plugin which will help you to add alexa rank in your website. In this article, we briefly explained to get alexa rank using php code
get alexa rank using php code
if you want to check the your website ranking as per alexa so you can use the following code in your php projects. There is very nice wordpress plugin which will help you to add the alexa rank in wordpress site. In this article I given PHP code for adding the alexa rank block on any website.
Alexa Rank Widget
http://data.alexa.com/data?cli=10&dat=s&url=wordpressapi
“http://data.alexa.com/data” 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.
<?php function AlexaRank( $url ) { preg_match( '#<POPULARITY URL="(.*?)" TEXT="([0-9]+){1,}"/>#si', file_get_contents('http://data.alexa.com/data?cli=10&dat=s&url=' . $url), $p ); return ( $p[2] ) ? number_format( intval($p[2]) ):0; } echo "purabtech.in/files/ Rank as per alexa.com: "; echo AlexaRank('purabtech.in/files/'); ?>
if you want to check the multiple website ranking in one shot than use the following PHP code.
<?php $domains = array( 'google.com', 'ask.com', 'yahoo.com', 'bing.com' ); foreach ( $domains as $domain ) echo $domain, ' - ', AlexaRank( $domain ), '<br />', PHP_EOL; ?>
Have fun!