I'm trying to have a page select a song at random from a dir of .mp3 files and play it. This is what I have so far http://pastebin.com/Jypx80RD I get this error:
Second argument has to be between 1 and the number of elements in the array
For this line: $random = array_rand($files, 2);
Try this:
$random = $files[rand(0, count($files) - 1)];
This should do it:
$random = array_rand($files);
$files
looks like it may be empty, from what I had to guess though.