PHP kôd:
class Mrzim_kad_skinem_titl_a_on_nije_sinhronizovan_sa_filmom{
public $period = 0;
function __construct($period, $subtitle)
{
$this->period = $period;
echo preg_replace_callback('#(\d{0,2}\:\d{0,2}\:([\d\,]+))#is', function($matches)
{
$value = $matches[0];
$value = explode(':', $value);
$x = explode(',', $value[2]);
$value[] = '0.'.$x[1];
$x = array_sum($value) + $this->period;
return $this->ms2hmu($x);
}, $subtitle);
}
function ms2hmu($s)
{
$hs = 0;
$ms = str_replace('0.', '', $s - floor($s));
if ($s > 3600)
$hs = floor($s / 3600);
$s = $s % 3600;
return str_pad($hs, 2, '0', STR_PAD_LEFT) . gmdate(':i:s', $s) . ($ms? '.'.$ms: '');
}
}
$Mrzim_kad_skinem_titl_a_on_nije_sinhronizovan_sa_filmom = new Mrzim_kad_skinem_titl_a_on_nije_sinhronizovan_sa_filmom(-2.2,
'1
00:00:20,000 --> 00:00:24,400
Altocumulus clouds occur between six thousand
2
00:00:24,600 --> 00:00:27,800
and twenty thousand feet above ground level.'
);