public static function getId($url)
    {
        if (strpos($url, 'youtube.com') !== false) {
            $url = parse_url($url);

            if (empty($url['query'])) {
                return false;
            }

            parse_str($url['query'], $url);

            return empty($url['v']) ? false : $url['v'];
        }

        if (preg_match('/youtu\.be\/([^?]+)/', $url, $matches)) {
            return $matches[1];
        }

        return false;
    }
public static function getId($url)
    {
        if (strpos($url, 'youtube.com') !== false) {
            $url = parse_url($url);

            if (empty($url['query'])) {
                return false;
            }

            parse_str($url['query'], $url);

            return empty($url['v']) ? false : $url['v'];
        }

        if (preg_match('/youtu\.be\/([^?]+)/', $url, $matches)) {
            return $matches[1];
        }

        return false;
    }
public static function getId ( $ url ) { if ( strpos ( $ url , 'youtube.com' ) !== false ) { $ url = parse_url ( $ url ) ; if ( empty ( $ url [ 'query' ] ) ) { return false ; } parse_str ( $ url [ 'query' ] , $ url ) ; return empty ( $ url [ 'v' ] ) ? false : $ url [ 'v' ] ; } if ( preg_match ( '/youtu\.be\/([^?]+)/' , $ url , $ matches ) ) { return $ matches [ 1 ] ; } return false ; }
Parses a YouTube url and returns the YouTube ID
@param string $url Video url
@return mixed Youtube ID or `false`
Parses a YouTube url and returns the YouTube ID