函数一段时间只返回1个结果

I would like to have a select with all the uploads files in the folder. I creat a function :

if (!defined('select_uploads')) 
{
    function select_uploads()
    {
        $adresse="partials/rapport_qualite/uploads/"; //Adresse du dossier.
        $dossier=Opendir($adresse); //Ouverture du dossier.

        while ($Fichier = readdir($dossier))
        {
             if ($Fichier != "." && $Fichier != "..") // Filtre anti-point ! 
             {
                 return '<option value="'.$Fichier.'">'.$Fichier.'</option>';
             }   
        }
    }
}

With this function i have only one result and not all the files.

For now when the if condition is satisfied it will return that particular option and break the loop and function. You should create a string with all the options and then return the string -

    $options = '';
    while ($Fichier = readdir($dossier))
    {
         if ($Fichier != "." && $Fichier != "..") // Filtre anti-point ! 
         {
             $options.= '<option value="'.$Fichier.'">'.$Fichier.'</option>';
         }   
    }
    return $options;

RETURN

If called from within a function, the return statement immediately ends execution of the current function, and returns its argument as the value of the function call.

If you're using PHP >= 5.5.0, then you can turn your function into a generator

if (!defined('select_uploads')) 
{
    function select_uploads()
    {
        $adresse="partials/rapport_qualite/uploads/"; //Adresse du dossier.
        $dossier=Opendir($adresse); //Ouverture du dossier.

        while ($Fichier = readdir($dossier))
        {
             if ($Fichier != "." && $Fichier != "..") // Filtre anti-point ! 
             {
                 yield '<option value="'.$Fichier.'">'.$Fichier.'</option>';
             }   
        }
    }
}

foreach(select_uploads() as $fileUpload) {
    echo $fileUpload;
}

Though it's cleaner to move the markup out of your select_uploads() and into the foreach loop instead

If you use a return statement, then the result will be returned and after that, the loop will not run. So you have to concatenate all the results to a string and return that one. Try like this

if (!defined('select_uploads')) 
{
    $tempvar='';
    function select_uploads()
    {
    $adresse="partials/rapport_qualite/uploads/"; //Adresse du dossier.
    $dossier=Opendir($adresse); //Ouverture du dossier.

    while ($Fichier = readdir($dossier))
    {
         if ($Fichier != "." && $Fichier != "..") // Filtre anti-point ! 
         {
             $tempvar.'= '<option value="'.$Fichier.'">'.$Fichier.'</option>';
         }   
    }
    }
return $tempvar;
}