getDiffNum.php如何处理长尾词查询结果差异?
- 内容介绍
- 文章标签
- 相关推荐
本文共计191个文字,预计阅读时间需要1分钟。
phpgetDiffNum.php: 如果 $num 值大于 $set 元素,则返回错误。计算 $numSet,然后初始化 $setpSet 数组。循环直到找到正确的差值。
getDiffNum.phpcount($set)){ return 'error:$num值大于$set元素'; } $numSet = count($set) - 1; for ($i = 0; $i < $num; $i++) { $setpSet[$i] = 0; } while (true) { for ($i = ($num - 1); $i >= 0 ; $i--) { if($setpSet[$i] > $numSet){ $setpSet[$i] = 0; $setpSet[$i - 1]++; } if($i - 1 == 0 && $setpSet[$i - 1] > $numSet){ return $newSet; } } $check = []; for ($i = ($num - 1); $i >= 0 ; $i--) { $check[$setpSet[$i]] = 0; } if(count($check) < $num){ $setpSet[$num - 1]++; continue; } $numArr = []; for ($i = 0; $i < $num ; $i++) { $numArr[] = $set[$setpSet[$i]]; } $newSet[] = implode(',', $numArr); $setpSet[$num - 1]++; } }
本文共计191个文字,预计阅读时间需要1分钟。
phpgetDiffNum.php: 如果 $num 值大于 $set 元素,则返回错误。计算 $numSet,然后初始化 $setpSet 数组。循环直到找到正确的差值。
getDiffNum.phpcount($set)){ return 'error:$num值大于$set元素'; } $numSet = count($set) - 1; for ($i = 0; $i < $num; $i++) { $setpSet[$i] = 0; } while (true) { for ($i = ($num - 1); $i >= 0 ; $i--) { if($setpSet[$i] > $numSet){ $setpSet[$i] = 0; $setpSet[$i - 1]++; } if($i - 1 == 0 && $setpSet[$i - 1] > $numSet){ return $newSet; } } $check = []; for ($i = ($num - 1); $i >= 0 ; $i--) { $check[$setpSet[$i]] = 0; } if(count($check) < $num){ $setpSet[$num - 1]++; continue; } $numArr = []; for ($i = 0; $i < $num ; $i++) { $numArr[] = $set[$setpSet[$i]]; } $newSet[] = implode(',', $numArr); $setpSet[$num - 1]++; } }

