Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4037576
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:21:54+00:00 2026-05-20T12:21:54+00:00

I want to get Video ID for YouTube or Vimeo via its Embed code

  • 0

I want to get Video ID for YouTube or Vimeo via its Embed code or from URL, Any solution to do this with PHP ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:21:54+00:00Added an answer on May 20, 2026 at 12:21 pm

    You could use preg_match to get the IDs. I will cover the expressions themselves later in this answer, but here is the basic idea of how to use preg_match:

    preg_match('expression(video_id)', "http://www.your.url.here", $matches);
    $video_id = $matches[1];
    

    Here is a breakdown of the expressions for each type of possible input you asked about. I included a link for each showing some test cases and the results.

    1. For YouTube URLs such as http://www.youtube.com/watch?v=89OpN_277yY, you could use this expression:

      v=(.{11})
      
    2. YouTube embed codes can either look like this (some extraneous stuff clipped):

      <object width="640" height="390">
          <param name="movie" value="http://www.youtube.com/v/89OpN_277yY?fs=...
          ...
      </object>
      

      Or like this:

      <iframe ... src="http://www.youtube.com/embed/89OpN_277yY" ... </iframe>
      

      So an expression to get the ID from either style would be this:

      \/v\/(.{11})|\/embed\/(.{11})
      
    3. Vimeo URLs look like http://vimeo.com/<integer>, as far as I can tell. The lowest I found was simply http://vimeo.com/2, and I don’t know if there’s an upper limit, but I’ll assume for now that it’s limited to 10 digits. Hopefully someone can correct me if they are aware of the details. This expression could be used:

      vimeo\.com\/([0-9]{1,10})
      
    4. Vimeo embed code takes this form:

      <iframe src="http://player.vimeo.com/video/<integer>" width="400" ...
      

      So you could use this expression:

      player\.vimeo\.com\/video\/([0-9]{1,10})
      

      Alternately, if the length of the numbers may eventually exceed 10, you could use:

      player\.vimeo\.com\/video/([0-9]*)"
      

      Bear in mind that the " will need to be escaped with a \ if you are enclosing the expression in double quotes.


    In summary, I’m not sure how you wanted to implement this, but you could either combine all expressions with |, or you could match each one separately. Add a comment to this answer if you want me to provide further details on how to combine the expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get all only youtube video ID from html code look the
I want to use oembed to get the embed code from youtube links with
I am trying to get the video URL of any YouTube video like this:
My code can upload the video to YouTube successfully, I want to get the
I want to play youtube videos in my application.I get this data from gdata.youtube.com
I want to get the v=id from YouTube’s URL with JavaScript (no jQuery, pure
I want to get a thumbnail image for videos from Vimeo. When getting images
so i continue from this question YouTube: get youtube title+ image+description like facebook `
I'm creating a Bookmarklet for YouTube, i want to get the ID from the
I have a media field through which I both embed video files from Youtube

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.