以下代码组合了 3 个用 url 和分数填充的数组,如果 url 匹配,则将分数相加以创建一个新数组。我现在正在尝试按降序在组合数组中创建一个排名列表,但我不太确定该怎么做
<?php
$combined = array();
foreach($bingArray as $key=>$value){ // for each bing item
if(isset($combined[$key]))
$combined[$key] += $value['score']; // add the score if already exists in $combined
else
$combined[$key] = $value['score']; // set initial score if new
}
// do the same for google
foreach($googleArray as $key=>$value){
if(isset($combined[$key]))
$combined[$key] += $value['score'];
else
$combined[$key] = $value['score'];
}
// do the same for bing
foreach($bingArray as $key=>$value){
if(isset($combined[$key]))
$combined[$key] += $value['score'];
else
$combined[$key] = $value['score'];
}
array_multisort($value['score'], SORT_DESC,$combined);
print_r($combined); // print results
?>
以下是我目前得到的输出
Warning: array_multisort() [function.array-multisort]:
Argument #1 is an unknown sort flag in /homepublic_html/agg_results.php on line 230
Array ( [time.com/time/] => 200 [time.gov/] => 297 [timeanddate.com/worldclock/]
=> 294 [timeanddate.com/] => 194 [en.wikipedia.org/wiki/Time] => 289
[worldtimezone.com/] => 190 [time100.time.com/]=> 188
[time.gov/timezone.cgi? Eastern/d/-5/java]
=> 186 [en.wikipedia.org/wiki/Time_(magazine)]
=> 275 [dictionary.reference.com/browse/time] => 182 [time.com/]
=> 100 [time.com/time/magazine]
=> 96 [time.is/] => 95 [tycho.usno.navy.mil/cgi-bin/timer.pl]
=> 94 [twitter.com/TIME] => 93 [worldtimeserver.com/] => 92 )
任何帮助都会是很棒的家伙和洋娃娃