See duration of a Youtube video?

1

How can I see the length of a video through id of the video?

With some research I found how to see the title but could not find the duration.

    $content = file_get_contents("http://youtube.com/get_video_info?video_id=".$id_vid);
    parse_str($content, $ytarr);
    $titulo_v = $ytarr['title'];

With the above code, I can see the title of the video but how do I make it last? Is it possible in the same way?

    
asked by anonymous 28.02.2018 / 18:09

1 answer

2

Inside the variable $ytarr has the index length_seconds that brings the duration of the video in seconds:

$seconds = $ytarr['length_seconds'];
    
28.02.2018 / 18:17