我正在创建元搜索引擎,但我被卡住了!我使用 php 向 3 个搜索引擎发送查询,并从每个搜索引擎中提取前 10 个网址。然后,我将这些 url 存储在一个带有相应分数的二维数组中,以用于聚合目的,即。第一个结果得到20分,第二个得到18分等等。
所以在下面的例子中,我用'php'查询搜索引擎并得到这些结果:
块引用
布莱科
数组 ( [url] => php.about.com/ [score] => 20 ) 数组 ( [url] => php.net/ [score] => 18 ) 数组 ( [url] => en.wikipedia.org /wiki/PHP [score] => 16 ) 数组 ( [url] => www.phpbuilder.com/ [score] => 14 ) 数组 ( [url] => blekko.com/ws/http://php. about.com/+/seo [score] => 12 ) 数组 ( [url] => www.w3schools.com/php/default.asp [score] => 10 ) 数组 ( [url] => phpnuke.org/ [分数] => 8 ) 数组 ( [url] => www.symfony-project.org/ [分数] => 6 ) 数组 ( [url] => www.phpconference.co.uk/ [分数] => 4 )
整个网络
数组 ( [url] => phpnuke.org/ [score] => 20 ) 数组 ( [url] => www.aardvarktopsitesphp.com/ [score] => 18 ) 数组 ( [url] => www.php.net / [score] => 16 ) 数组 ( [url] => www.php.net/downloads.php [score] => 14 ) 数组 ( [url] => php.net/manual [score] => 12 )数组 ( [url] => www.php.net/manual/en/ [score] => 10 ) 数组 ( [url] => www.php.net/docs.php [score] => 8 ) 数组 ( [ url] => www.php.net/license/ [score] => 6 ) 数组 ( [url] => www.phplinkdirectory.com/ [score] => 4 )
必应
数组 ( [url] => www.php.net/ [score] => 20 ) 数组 ( [url] => en.wikipedia.org/wiki/PHP [score] => 18 ) 数组 ( [url] => www.php.net/downloads.php [分数] => 16 ) 数组 ( [url] => www.w3schools.com/php/default.asp [分数] => 14 ) 数组 ( [url] => windows. php.net/download [score] => 12 ) 数组 ( [url] => windows.php.net/ [score] => 10 ) 数组 ( [url] => www.tizag.com/phpT/ [score] => 8 ) 数组 ( [url] => wiki.php.net/ [score] => 6 ) 数组 ( [url] => qa.php.net/ [score] => 4 ) 数组 ( [url] = > www.php.com/ [分数] => 2)
我想做的是结合所有这些结果,删除重复的 url,但添加分数并创建一个新列表,其中包含可能看起来像这样的聚合结果:
数组([url] => www.php.net/ [score] => 54)
数组([url] => en.wikipedia.org/wiki/PHP [score] => 34)
数组([url] => www.w3schools.com/php/default.asp [score] =>24)
等等
我只是在寻找实现这一目标的最有效方法,任何建议将不胜感激。谢谢