Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

Getting the YouTube ID with PHP?

Today post is about retrieving Youtube ID from its URL. The below PHP code will allow you to extract the ID number from the given youtube URL.

function to get the Youtube ID

 * get_video_id()
 * @param mixed $url
 * @return string
function get_video_id($url)
    if (!empty($url)) {
        parse_str(parse_url($url, PHP_URL_QUERY), $result);
        return $result['v'];
    } else {
        return FALSE;
//function reference
// parse_url() :
//parse_str() :

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments