I am trying to get the video code from a youtube link like below:
https://www.youtube.com/watch?v=sLnwdjQQlIw
Specifically, I am trying to get the code that follows "v=".
The problem comes when the link looks like below:
How would I go about getting the video code from that link?
Here is what I have so far:
<?php
if(isset($_POST["Search"]))
{
$url = $_POST["URL"];
$value = (explode('v=', $url));
$videoId = $value[1];
}
?>
<form method="post" class="form-group">
<input name="url" type="url" class="form-control form-control-lg mb-3" placeholder="https://www.youtube.com/watch?v=9a5TF2U-Fa4" required>
<button style="background-color:#f2ae06;border:none" name="Search" class="btn btn-primary btn-lg btn-block">Get</button>
</form>