noirsith Posted July 29, 2008 Share Posted July 29, 2008 I'm developing a typing test using php, and have figured out a way to check the speed but not accuracy. All the info being typed by the person is stored into a table as a varchar but I don't know how I would go about parsing it to see how accurate it is compared to the actual file they were copying. Is there a way to do this or do I have to send each word into a table cell and compare it to what it should be? If so how would I go about doing that? Thank you much! Link to comment https://forums.phpfreaks.com/topic/117179-typing-test/ Share on other sites More sharing options...
MatthewJ Posted July 29, 2008 Share Posted July 29, 2008 take a look at the php manual for strcmp() Link to comment https://forums.phpfreaks.com/topic/117179-typing-test/#findComment-602736 Share on other sites More sharing options...
DarkWater Posted July 29, 2008 Share Posted July 29, 2008 Matthew3, the strcmp() function is basically the same as $str1 == $str2, but it only uses the C locale. Now, back on topic...I'd suggest the similar_text() function: $str1 = "Lol"; $str2 = "Rofl"; $percent = (float) 0; similar_text($str1, $str2, $percent); echo $percent; //Will echo 57.1428571429 Link to comment https://forums.phpfreaks.com/topic/117179-typing-test/#findComment-602741 Share on other sites More sharing options...
MatthewJ Posted July 29, 2008 Share Posted July 29, 2008 Yeah, go figure when I saw the word compare in his question my brain just went to strcmp... Link to comment https://forums.phpfreaks.com/topic/117179-typing-test/#findComment-602745 Share on other sites More sharing options...
DarkWater Posted July 29, 2008 Share Posted July 29, 2008 Heh. =P And for the thread starter...you can use that function on the entire input string and the entire expected string at once and it'll be pretty accurate. Link to comment https://forums.phpfreaks.com/topic/117179-typing-test/#findComment-602747 Share on other sites More sharing options...
noirsith Posted July 29, 2008 Author Share Posted July 29, 2008 I will try that, and let you know if it works, thanks so much for your quick response. Link to comment https://forums.phpfreaks.com/topic/117179-typing-test/#findComment-602780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.