doulu1945 2016-12-20 18:40
浏览 59

排序alexa排名直播

An excel file contains 2 columns and 100 rows. The first column is serial numbers and the second one is domain names. I am able to get alexa ranks of the websites using this script. I need the ranks obtained be sorted in ascending order. Also the respected urls should be sorted accordingly. What should I do?

<?php $data = wp_excel_cms_get("top100"); ?>
<?php foreach($data as $entry): ?>

<? $url = "http://". $entry[1]; 
$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url='.$url);
$rank=isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0;
$web=(string)$xml->SD[0]->attributes()->HOST;
?>

<?php echo  $rank."&nbsp;";?><a href ="<?php echo "http://". $entry[1]; ?>"target="_blank"><?php echo $entry[1];?></a>
<hr />
<?php endforeach; ?>
  • 写回答

1条回答 默认 最新

  • duanoucuo7045 2016-12-20 20:45
    关注

    Use two loops.

    First loop queries alexa and stores results in an array rank => host. Then sort array by keys (see: http://php.net/manual/en/function.ksort.php).

    Then loop over sorted array to output data.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用