itmo-php-course/engine/app/model/MusicModel.php

22 lines
467 B
PHP

<?php
namespace App\Model;
class MusicModel
{
static function getData()
{
$box = [];
if ($handle = opendir('./uploads')) {
while (false !== ($entry = readdir($handle))) {
$ext = pathinfo($entry, PATHINFO_EXTENSION);
if ($ext == 'mp3') {
array_push($box, "./uploads/$entry");
}
}
closedir($handle);
}
return $box;
}
}