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.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里