使用scandir()根据传递的变量(PHP)查找目录中的目标文件夹

iam using this code to show me the documents in a default Folder path.

<?php
$307 = $_GET['307'];
$2949 = $_GET['2949'];

$folder = '//Server/folder/307_XY28/2949_XY_128';

$alldata = scandir($folder); 

foreach ($alldata as $data) {
    $datainfo = pathinfo($folder."/".$data); 
    $size = ceil(filesize($location."/".$data)/1024); 
    //1024 = kb | 1048576 = MB | 1073741824 = GB
    if ($data != "." && $data != ".."  && $data != "_notes") { 
    ?>
    <li><a href="<?php echo $datainfo['dirname']."/".$datainfo['basename'];?>"><?php echo $datainfo['filename']; ?></a> (<?php echo $datainfo['extension']; ?> | <?php echo $size ; ?>kb)</li>
<?php
    };
 };
?> 

Under the Path: //Server/folder/ are much more folders with other numbers and content.

What i want is that I can check the global folder: //Server/folder/ with the received number from the previous page eg.307 in the foldername (eg.307_XY28) if it was found than check the subfolder with the next number eg. 2949. If the folder eg.2949_XY_128' exist show me the documents inside how I have it now.

Thank you for the help