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.
Try This: It will Work, I used original code found in answers and did some tweaking by adding
array($files)
in the$random = array_rand();
variable statementYou will first need to put the PHP code in the body like this
next add this just outside that php code in the body
Please Notice the echo output in the src file. This will ensure it gets outputted to your page. Also don't forget to use the ; at the end of every php variable statement as this can through some errors.
This should do it:
Then do this:
array_rand returns what random index it chose, so you'll need to do this: