PHPファイル取得配列yahoo音楽

1283 ワード


==>index.php
==>mp3s
          ==>file1
          ==>file2
          ==>file3
<?php

$dir = 'mp3s';

$handle = opendir($dir);
$mp3s = array();
while($file = readdir($handle))
{
if($file != '.' && $file != '..')
$mp3s[] = $file;
}
closedir($handle);
echo "<pre>";
print_r($mp3s);

?>

yahoo media player
index.php
<?php

$dir = 'mp3s';

$handle = opendir($dir);
$mp3s = array();
while($file = readdir($handle))
{
if($file != '.' && $file != '..')
$mp3s[] = $file;
}
closedir($handle);

?>

<html>
<head>
<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>
</head>
<body>

<?php

foreach($mp3s as $key => $value)
{
echo "<a href=\"$dir/$value\">" . $value . '</a><br />';
}

?>

</body>
</html>