Skip to content

Instantly share code, notes, and snippets.

@garex
Created September 26, 2018 04:12
Show Gist options
  • Save garex/8557d8568b988e5db137b0ba373e5766 to your computer and use it in GitHub Desktop.
Save garex/8557d8568b988e5db137b0ba373e5766 to your computer and use it in GitHub Desktop.
nhl vtt concat
<?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