我已经帮助创建了一个从关联数组中获取元素的组合数组,这些数组具有从搜索引擎中获取的url和分数,当urls匹配时,分数被添加在一起组合阵列,这里是代码在组合数组中添加额外的元素
$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
}
则相同的代码跑了$ googleArray,这工作得很好,但现在我想补充一点,有以下
foreach($jsonObj->d->results as $value)
{ $i = 0;
$bingArray[str_replace ($find, '', ($value->{'Url'}))] = array(
//'title'=> $value->{'Title'},
//'snippet' => $value->{'Description'},
'score' => $score--
);
代码被注释掉的值
我敢肯定,它很容易改变第一个foreach循环做到这一点,但我不知道如何,请任何帮助请
可不可以给结果的例子分数? –