Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个这样的数据库条目:
video_id | likes | dislikes 654 5 12
我想要做的是将喜欢和不喜欢的数量转换为谷歌丰富网页摘要的 5 星评级。
你有什么想法?一些代码?
要获得 1 到 5 之间的评分,您可以执行以下操作:
$rating = 1 + 4 * $likes / ($likes + $dislikes);
不过,请记住要特别注意没有选票的情况。