I didn’t write the ‘conversion’ part of this… no sense in reinventing the wheel… but I am trying to adapt for my uses and am getting a blank screen when I run it… I have no idea what’s wrong with it… any help would be appreciated!!!
[php]
<?php $dur = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=Um3f4BJwCc4&key=AIzaSyBw1asGhkxHxFf6JqyNrTqIeJ9sjMKFcX4"); $dury =json_decode($dur, true); foreach ($dury['items'] as $d) { $duration= $d['contentDetails']['duration']; echo "";
print_r($duration);
function NormalizeDuration($duration){
preg_match('#PT(.*?)H(.*?)M(.*?)S#si',$duration,$out);
if(empty($out[1])){
preg_match('#PT(.*?)M(.*?)S#si',$duration,$out);
if(empty($out[1])){
preg_match('#PT(.*?)S#si',$duration,$out);
if(empty($out[1])){
return '00:00';
}
}else{
if(strlen($out[1])==1){ $out[1]= '0'.$out[1]; }
if(strlen($out[2])==1){ $out[2]= '0'.$out[2]; }
return $out[1].':'.$out[2];
}
}else{
if(strlen($out[1])==1){ $out[1]= '0'.$out[1]; }
if(strlen($out[2])==1){ $out[2]= '0'.$out[2]; }
if(strlen($out[3])==1){ $out[3]= '0'.$out[3]; }
return $out[1].':'.$out[2].':'.$out[3];
}
}
}
?>
[/php]
How do I actually print out the return?
Thanks!!

