This content originally appeared on DEV Community and was authored by Teddy Zugana
function getLongestMatchingSubstring($str1, $str2)
{
$len_1 = strlen($str1);
$longest = '';
for($i = 0; $i < $len_1; $i++){
for($j = $len_1 - $i; $j > 0; $j--){
$sub = substr($str1, $i, $j);
if (strpos($str2, $sub) !== false && strlen($sub) > strlen($longest)){
$longest = $sub;
break;
}
}
}
return $longest;
}
This content originally appeared on DEV Community and was authored by Teddy Zugana
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
Teddy Zugana | Sciencx (2021-07-29T01:18:38+00:00) PHP Damarau levenstein on Longest Match SubString. Retrieved from https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/
" » PHP Damarau levenstein on Longest Match SubString." Teddy Zugana | Sciencx - Thursday July 29, 2021, https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/
HARVARDTeddy Zugana | Sciencx Thursday July 29, 2021 » PHP Damarau levenstein on Longest Match SubString., viewed ,<https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/>
VANCOUVERTeddy Zugana | Sciencx - » PHP Damarau levenstein on Longest Match SubString. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/
CHICAGO" » PHP Damarau levenstein on Longest Match SubString." Teddy Zugana | Sciencx - Accessed . https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/
IEEE" » PHP Damarau levenstein on Longest Match SubString." Teddy Zugana | Sciencx [Online]. Available: https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/. [Accessed: ]
rf:citation » PHP Damarau levenstein on Longest Match SubString | Teddy Zugana | Sciencx | https://www.scien.cx/2021/07/29/php-damarau-levenstein-on-longest-match-substring/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.