Re: Can I get a simple php code to measure how many words per minute someone can type?
Although it is possible, you will find that the typing speed php calculates will be slower than the real typing speed due to page loading and submitting time. For this reason you should deduct about 1 second from the overall time if the page has no graphics.
As for how to make it work, I would suggest placing in a hidden field the time the page was loaded then when the page is submitted, that time that was recorded can be compared to the current time to work out how long it took. Then do number of characters they typed devided by 3. Then do time it took devided by the previous result (the devide by 3 result). Then do 1 devided by the result. Really simple stuff but as I mentioned, an online typing test will not be 100% accurate due to page loading time and the time for submitting the results. Also note that when timing typing speed, one word normally = 3 characters.
Re: Can I get a simple php code to measure how many words per minute someone can type?
PHP would not be the best way to do this, not only due to the fact that page load times need to be taken into consideration (as already mentioned) but also because alot of the typing speed tests also take into account accuracy of the words typed. The code by cwarn23 above will count how many characters/words have been typed into a textbox and how long it took (roughly) but this would not stop you typing gibberish or 'a a a a a a a '....etc into the box.
You would really need something client-side (JavaScript maybe if it must be a web app) and a preset paragraph(s) to be typed. The script would then need to analyze the text as it is typed to make sure the words are input correctly, and if they are not then to make this count against the user. While this could be done in PHP, it is not going to be the simplest or easiest solution.
This is not a matter of 'basic code'.
Last edited by Will Gresham; Mar 22nd, 2009 at 1:38 am.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.