I know there are many techniques and methods to comparing two
Strings, and find out if two
Strings are equal or not.
I want to do something like this:
Var Str1 = "Hello How are you?"; var Str2 = "Hello I am ravi.";
str1 and display the number count of mismatching words.
Both strings contain 4 words each. It should display you missed three words from
I have one web page (web task) where a user needs to listen an audio and transcribe it. So I want to know how many words user misses from the transcribed original audio.
This is as simple as converting both the strings to an array and then computing the difference of arrays.
$arr1 = explode(' ', strtolower($str1)); $arr2 = explode(' ', strtolower($str2)); echo 'You missed ' . count(array_diff($arr1, $arr2)) . ' words from str 1';
Use explode to convert the
Arrays and count the difference between the two
$Str1 = "Hello How are you?"; $Str2 = "Hello I am ravi"; $st1 = (explode(" ", $Str1)); $st2 = (explode(" ", $Str2)); $result = array_diff($st1, $st2); echo count($result);
Find and format difference between two strings in PHP