Reputation: 1393
I am using the code bellow to get random video and i need to add a title also. Each video url must have a title also
Any suggestion?
<?php
$video_array = array
('http://www.youtube.com/embed/rMNNDINCFHg',
'http://www.youtube.com/embed/bDF6DVzKFFg',
'http://www.youtube.com/embed/bDF6DVzKFFg');
shuffle($video_array);
$video = $video_array[0];
?>
<iframe width='1006' height='421' src='<?php echo $video; ?>' title='TITLE HERE' frameborder='0' allowfullscreen></iframe>
Regards Irene
Upvotes: 0
Views: 220
Reputation: 31749
Store the tile in the array and print it -
<?php
$video_array = array(
array('url' => 'http://www.youtube.com/embed/rMNNDINCFHg', 'title' => 'ABC'),
array('url' => 'http://www.youtube.com/embed/bDF6DVzKFFg', 'title' => 'DSF'),
array('url' => 'http://www.youtube.com/embed/bDF6DVzKFFg', 'title' => 'RYUY')
);
shuffle($video_array);
$video = $video_array[0];
?>
<iframe width='1006' height='421' src='<?php echo $video['url']; ?>' title='<?php echo $video['title']; ?>' frameborder='0' allowfullscreen></iframe>
Upvotes: 7