在html中嵌入随机命名的mp3 [英] embed randomly named mp3 in html

查看:101
本文介绍了在html中嵌入随机命名的mp3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我的代码:

 < embed src =/ sound / lowyourchicken.mp3
width = 140height =40autostart =trueloop =TRUE>
< / embed>

我想用.mp3的src来解释有很多随机命名的。 mp3文件放在 / sound / 目录中,并在每次打开页面时随机选择一个。我的服务器支持PHP,但我希望尽可能简单。


$ b

  $ files = glob(/ path /to/directory/*.mp3\" ); 
$ random = array_rand($ files)

然后执行此操作:

 < embed src =<?php echo $ random?> 
width =140height =40autostart =trueloop =TRUE>
< / embed>


Here's my code:

<embed src="/sound/lowyourchicken.mp3" 
width="140" height="40" autostart="true" loop="TRUE"> 
</embed> 

I would like the src for the .mp3 to take in to account that there are many randomly named .mp3 files in the /sound/ directory, and to choose one at random each time the page is opened. Any clues for me?

My server is PHP enabled but I'd like to keep this as simple as possible.

解决方案

This should do it:

$files = glob("/path/to/directory/*.mp3");
$random = array_rand($files)

Then do this:

<embed src="<?php echo $random ?>" 
width="140" height="40" autostart="true" loop="TRUE"> 
</embed> 

这篇关于在html中嵌入随机命名的mp3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆