HTML interesse |
|
Maar hoe ziet je input eruit, dus de waarde van $film?
Is dat gewoon de URL van een youtube-film?
In dat geval zou je het ook zo kunnen doen:
<?php
$youtube_url = 'https://www.youtube.com/watch?v=d2TUBF7q8EE';
preg_match( '/[\\?\\&]v=([^\\?\\&]+)/', $youtube_url, $results );
$id = $results[1];
?>
<?php $youtube_url = 'https://www.youtube.com/watch?v=d2TUBF7q8EE'; preg_match( '/[\\?\\&]v=([^\\?\\&]+)/', $youtube_url, $results ); $id = $results[1]; ?>
En dan vervolgens de iframe:
<iframe src="https://www.youtube.com/embed/<?php echo $id; ?>" width="400" height="300" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/ <?php echo $id; ?>" width="400" height="300" frameborder="0" allowfullscreen></iframe>
In jou geval zou dat dan dus zo kunnen:
<?php
if ( $film ) :
preg_match( '/[\\?\\&]v=([^\\?\\&]+)/', $film, $results );
$id = $results[1];
?>
<iframe src="https://www.youtube.com/embed/<?php echo $id; ?>" width="400" height="300" frameborder="0" allowfullscreen></iframe>
<?php
endif;
<?php if ( $film ) : preg_match( '/[\\?\\&]v=([^\\?\\&]+)/', $film, $results ); $id = $results[1]; ?> <iframe src="https://www.youtube.com/embed/ <?php echo $id; ?>" width="400" height="300" frameborder="0" allowfullscreen></iframe> <?php endif;
|