doulu1907 2018-06-28 21:13 采纳率: 100%
浏览 93

使用php或js / jquery按顺序匹配字符串中的单词

i have a program to test candidates typing speed. they basicly follow string for 3 mins. after 3 mins i piece string into array in php and compare by order.

this code have serial errors like; 1- when candidates jumps between rows like up and down order confuses in algorithm and miscalculates matching words. 2- in one session we have 100 candidates typing. it means my wampserver will take 100 requests to compare huge strings at the same time. it causes to not respond to some candidates. that'll take us to re test these candidates since we couldn't get results from wampserver.

since i need to keep results in mysql, i'm thinking of loading calculate jobs to javascript in their browser and only send results to wampserver to write these down to mysql.

i'm searching alternative ways to solve these problems for 5 months at least and here i'm open to any kind of suggestions.

should i make calculations at javascript by spliting string into words to array and compare? or should i keep it in php wampserver but how to solve these kind of instant 100 requests run smoothly.

thanks in advance.

  • 写回答

1条回答 默认 最新

  • dongsu3664 2018-06-28 22:06
    关注

    Here is a simple example on how to compare 2 arrays

    var arr1 = 'This is an example'.split(' ');
    var arr2 = ['This', 'is', 'a', 'example'];
    
    for (var i = 0; i < arr2.length; i++)
      if (arr1[i] !== arr2[i])
        console.log(arr1[i], 'Didnt match at index', i);

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?