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

  • SEARCH
  • Home
  • 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 8207211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:55:32+00:00 2026-06-07T08:55:32+00:00

I am trying to obtain embeded code through extracting variables from Youtube video URLs.

  • 0

I am trying to obtain embeded code through extracting variables from Youtube video URLs. So far I have the old way of embedding working but not the Iframe way. The Iframe works fine if the url only has the 11 characters after “watch?v=” but the issue comes when the url contains “&feature=g” the 11 characters. Is there a solution to strip off the “&feature=g” or maybe a better way? Second and less important, every time i click autoplay i dont obtain an autplay result with video? Here is my EXAMPLE

PHP for obtaining embeded code

<?php
$vari ='';

if($_POST)
{
    $vari       = $_POST['yurl'];
    $hth        = 300; //$_POST['yheight'];
    $wdth       = 500; //$_POST['ywidth'];
    $is_auto    =   0;

    $step1 =explode ('v=', $vari);
    $step2 =explode ('&amp;',$step1[1]);

    if(isset($_POST['yautop'] ))
    {
        if($_POST['yautop'] == 1)
            $is_auto    =   1;
    }
    $auto1  = '?autoplay='.$is_auto;
    $auto2  = '&autoplay='.$is_auto;

//Iframe code

echo  ('<iframe src="http://www.youtube.com/embed/'.$step2[0].'" frameborder="0" width="'.$wdth.'" height="'.$hth.'"></iframe>');

//Old way to embed code
echo  ('<embed width="'.$wdth.'" height="'.$hth.'" type="application/x-shockwave-flash" src="http://www.youtube.com/v/'.$step2[0].'" wmode="transparent" embed="" /></embed>');
}
?>

html

<html>

<form method="post" action="">
URL:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" value="<?php $vari ?>" name="yurl"> <!--$vari-->
<br>
<br>
Autoplay:&nbsp;
<input type="checkbox" value="<?php $auto1; $auto2; ?>" name="yautop">  <!--$auto1 $auto2-->
<br>
<input type="submit" value="Generate Embed Code" name="ysubmit">
<br>
</form>

</html>
  • 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-06-07T08:55:33+00:00Added an answer on June 7, 2026 at 8:55 am

    Rather than multiple explode() calls you can extract the vid ID via REGEX.

    $vid_url = "http://www.youtube.com/watch?v=2RgTmJ5oCCA&feature=g-vrec";
    preg_match('/(?<=v=)[^&]+/', $vid_url, $vid_id);
    //the vid's ID is now in $vid[0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to obtain the n-th elements from a list of tuples. I have
I am trying to obtain and transfer information from a HTML web form (through
I'm trying to obtain the most liked comments from a video of my choice
I'm trying to obtain a list of videos from Youtube to be displayed on
I am trying to obtain the <RowDefinitions> element from my Xaml, through Javascript, so
I'm trying to obtain the machine precision on gmp variables. To that end, I
OK, I have been trying to obtain the id of a particular link, but
I'm trying to log into a site and obtain the code back, but i'm
I am trying to obtain the ip address from a text file so when
I'm trying to obtain the price from a field called DiscountMarkupPriceRate1 on my second

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.