Created
September 26, 2018 04:12
-
-
Save garex/8557d8568b988e5db137b0ba373e5766 to your computer and use it in GitHub Desktop.
nhl vtt concat
This file contains 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
<?php | |
function vtt_concat($t1, $t2) { | |
for ($i = 1; $i < strlen($t1); $i++) { | |
$t1_part = substr($t1, -$i); | |
$t2_has_t1_part = (strstr($t2, $t1_part) !== false); | |
if ($t2_has_t1_part) { | |
continue; | |
} elseif ($i == 1) { | |
break; | |
} | |
$i--; | |
$t1 = substr($t1, 0, -$i); | |
} | |
return $t1 . $t2 . "\n"; | |
} | |
echo vtt_concat('What is you', 'is your name?'); | |
echo vtt_concat('What is your', ' name?'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment