Summary
I am trying to find name matching percentage in php but before that I need to rearrange the words in string according to 1st string.
What is the source code about?
I have two strings. First I am adding both strings to array if space is found in string add it into array. $arraydataBaseName and $arraybankData from my first array i.e $arraydataBaseName I am searching all the values of $arraybankData and getting the Key. I am getting the key arrangement properly but unable to arrange the value at their specific places into new array.
$dataBaseName = "Jardine Lloyd Thompson";
$bankdata = "Thompson Thompson Jardine";
$replacedataBaseName = preg_replace("#[\s]+#", " ", $dataBaseName);
$replacebankData = preg_replace("#[\s]+#", " ", $bankdata);
$arraydataBaseName = explode(" ",$replacedataBaseName);
$arraybankData = explode(" ",$replacebankData);
echo "<br/>";
print_r($arraydataBaseName);
$a="";
$i="";
$arraysize = count($arraydataBaseName);
$push=array();
for($i=0;$i< $arraysize;$i++)
{
if(array_search($arraybankData[$i],$arraydataBaseName)>0)
{
${"$a$i"} = array_search($arraybankData[$i],$arraydataBaseName);
//echo ${"$a$i"};
array_push($push,${"$a$i"});
}
}
print_r($push);
Case 1:
Input
DatabaseName = Jardine Lloyd Thompson
BankName = Thompson Jardine Lloyd
Output
ExpectedOutput = Jardine Lloyd Thompson
Case 2:##
Input
DatabaseName = Jardine Lloyd Thompson
BankName = Thoapson Jordine Llayd
If the words are not found in the above DatabaseName then the expected search would be based on leventish algorithm word which have less distance that would be considered as the key
Output
ExpectedOutput = Jordine Llayd Thoapson
Question Update
When the user input $bankdata
contains more words remaining unmatchable, I need to append those to the end.