ページが読み込まれるたびにphp配列からランダムなYouTubeビデオを読み込むこのphp/htmlコードがあります。しかし、配列内の次のビデオと前のビデオをロードするために、次と前のボタンが必要です。一度に 1 つのビデオのみをロードする必要があります。私はこれを持っています:
<?php $videos = array("0jBRY_Aki9s","1czXvHSjDac","1kbiUiRfnh8","377kKBi6anQ");
$rand = array_rand($videos);
$rand_key = $videos[$rand];
$numOfItems = count($videos);
echo "<iframe width='375' height='310'
src='http://www.youtube.com/embed/$rand_key?&fmt=22&autoplay=1'> </iframe>";?>
<span onclick="<?php $clip = next($videos);
echo "<iframe style='float:left;' width='375' height='310'
src='http://www.youtube.com/embed/$clip?&fmt=22&autoplay=1'>
</iframe>";?> ">next</span>
iframe の現在のビデオを変更するために PHP の "next" メソッドを使用する方法はありますか?