doufei8691 2012-11-19 23:01 采纳率: 100%
浏览 45
已采纳

表格查找PHP中的数字数据

I have a fairly large table (~5 MB csv file) stored on our server that consists of purely numeric data giving some result based on two parameters, e.g.

A     B     Output
-----------------------
1     1     20
1     2     21
1     3     22
2     1     23
2     2     24
2     3     25
...   ...   ...

What I'd like to do is, based on the user's input, find the closest parameters then use the appropriate output. For example, using the table above, if the user select A=1.1 and B=2.9, the Output would be 22.

What is the best way to do this table lookup in php? Do I need to load the entire table into PHP? Instead of a csv-file, should I make it binary so that the file size is smaller and loads faster? Or should I create a mySQL database and perform a look-up that way?

TL;DR: I'm looking for the most efficient way to perform a nearest-neighbor table look-up on strictly numeric data.

  • 写回答

1条回答 默认 最新

  • doumigu9594 2012-11-19 23:11
    关注

    If mysql is available, my suggestion would be to use a table and do a look up. I guess rounding the user input to the nearest integer before lookup should give you the closest.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型