1
I wish that whenever someone walks into a page some random mail is reproduced that is in a folder.
I tried to use this
<?php
$dir_path = "data/";
$extensions_array = array('mp3');
if(is_dir($dir_path))
{
$files = scandir($dir_path);
for($i = 0; $i < count($files); $i++)
{
if($files[$i] !='.' && $files[$i] !='..')
{
$file = pathinfo($files[$i]);
$extension = $file['extension'];
if(in_array($extension, $extensions_array))
{
echo "<audio loop='loop' autoplay='autoplay'>
<source src='$dir_path$files[$i]'>
</audio> ";
}
}
}
}
?>
But I enter the page it carries all Audios at once. Someone can help me ?
when I look at the source code appears all the audios that are in the folder.
<audio loop='loop' autoplay='autoplay'> <source src='data/defacee.mp3'></audio>
<audio loop='loop' autoplay='autoplay'> <source src='data/sound.mp3'> </audio>
Thanks, it worked. however I used a shuffle($files); before for, and a break; after audio echo
– Natanael Nicolas