I need to get the ID of a youtube video to dynamically embed the video in my webpage.
I am looking for a way to achieve the following in twig
:
$url="https://www.youtube.com/watch?v=hqDT5_4z_YI"
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
echo $my_array_of_vars['v'];
// Output: hqDT5_4z_YI
Is this even possible or should I use JavaScript
to do this?