更改电子表格公式以使其适用于 PHP
多年来,我一直使用数学公式来确定留言板的相对活动水平。现在我想在 php 搜索引擎中使用该公式来替换不起作用的 Google 页面排名系统。
使用的数据项是:成员 (B2)、帖子 (D2)、主题 (C2) 和论坛创建日期 (E2)。在电子表格中,基本公式如下所示:
=SUM(((((((B2/E2)+(C2/E2)+(D2/E2)))*0.419)))+((((((B2/C2)+(B2/D2))/2)+(((C2/B2)+(D2/B2))/3)-3.4777)))/7)+0.0017
硬(非生成)数字是我手动计算的数字,以提供似乎提供接近 Alexa 流量排名的结果的输出,并且我每年都会修改它们。输出始终保留到小数点后 4 位。
for years now I have used a math formula to determine relative activity levels for message boards. Now I would like to use that formula in a php search engine to replace the non-functioning Google Page Ranking system.
The data items used are: Members (B2), Posts (D2), Topics (C2), and the Boards creation date (E2). In the spreadsheet the base formula looks like this:
=SUM(((((((B2/E2)+(C2/E2)+(D2/E2)))*0.419)))+((((((B2/C2)+(B2/D2))/2)+(((C2/B2)+(D2/B2))/3)-3.4777)))/7)+0.0017
The hard (non-generated) numbers are numbers I calculated by hand to provide output that seems to provide results close to what would be Alexa Traffic rankings and I modify them each year. The output is always held to 4 decimal places.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,你的方程可以简化很多。现在,您看到了:
SUM 函数似乎没用,因为您只有不同的单元格,没有范围。另外,很多括号都可以删除。因此,该函数变成这样:
将其写为单行:
要使其成为 PHP,请用变量替换单元格地址:
您可能希望从中创建一个函数,该函数将返回四舍五入到小数点后 4 位的结果:
您可以像这样调用该函数(我不知道日期 E2 是什么样子,因此 30000):
希望有帮助。
First of all, your equation can be simplified quite a lot. Now, you have this:
The SUM function seems useless, as you have only distinct cells, not ranges. Also, a lot of the parenthesis can be removed. Thus, the function becomes this:
Writing that as an one liner:
To make it PHP, substitute the cell addresses with variables:
You probably want to make a function out of that that will return the result rounded in 4 decimal places:
And you could call that function like this (I have no idea what the date E2 looks like, thus 30000):
Hope that helps.
如果没有有关实际电子表格的更多详细信息,就很难找到可行的解决方案。不过,一般来说,您可能想要编写一个如下所示的函数:
如果您从电子表格中发布一些示例行,那么创建一个有效的解决方案会容易得多。我不确定我是否完全理解您对 sum 函数的调用做了什么,因此我将其从示例中删除了。
Without some more detail about the actual spread sheet, it's very very difficult to come up with a working solution. In general though, you'd probably want to write a function that looks something like this:
If you post some example rows from your spreadsheet it will be much easier to craft a solution that works. I'm not sure I fully understand what your call to the sum function did, so I removed it from my example.