Created
June 29, 2016 03:27
-
-
Save firejune/f70739fbf0346b45df64b73323397ef9 to your computer and use it in GitHub Desktop.
Compare Two Strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function compareText($str1, $str2) { | |
$str1 = split(" ", $str1); | |
$str2 = split(" ", $str2); | |
$count = 0; | |
for ($i = 0; $i < sizeof($str1); $i++) { | |
for ($j = 0; $j < sizeof($str2); $j++) { | |
if ($str1[$i] == $str2[$j]) $count++; | |
} | |
} | |
return ($count * 100) / sizeof($str1); | |
} | |
echo compareText('스타크래프트2 - 군단의 심장 시네마틱', 'RT @firejune: 스타2 군단의 심장 시네마틱 http://t.co/zqeBuuOI') | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment