private static function doDirectoryOptions($basename, $filenames, $options) {
    $name_list = [];
    $results = [];
    // We need to know the path to the file so we can check if it's a directory.
    foreach($filenames as $file) {
      $name_list[] = ['name' => $file,
                      'path' => implode(DIRECTORY_SEPARATOR, [
                                        rtrim($basename, DIRECTORY_SEPARATOR),
                                        ltrim($file, DIRECTORY_SEPARATOR)]),
      ];
    }
    foreach($name_list as $name_and_path) {
      $name = $name_and_path['name'];
      $isdir = is_dir($name_and_path['path']);
      if (($options & GLOB_MARK) && $isdir) {
        $name = rtrim($name, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
      }
      if ($options & GLOB_ONLYDIR) {
        if ($isdir) {
          $results[] = $name;
        }
      } else {
        $results[] = $name;
      }
    }
    return $results;
  }
private static function doDirectoryOptions($basename, $filenames, $options) {
    $name_list = [];
    $results = [];
    // We need to know the path to the file so we can check if it's a directory.
    foreach($filenames as $file) {
      $name_list[] = ['name' => $file,
                      'path' => implode(DIRECTORY_SEPARATOR, [
                                        rtrim($basename, DIRECTORY_SEPARATOR),
                                        ltrim($file, DIRECTORY_SEPARATOR)]),
      ];
    }
    foreach($name_list as $name_and_path) {
      $name = $name_and_path['name'];
      $isdir = is_dir($name_and_path['path']);
      if (($options & GLOB_MARK) && $isdir) {
        $name = rtrim($name, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
      }
      if ($options & GLOB_ONLYDIR) {
        if ($isdir) {
          $results[] = $name;
        }
      } else {
        $results[] = $name;
      }
    }
    return $results;
  }
private static function doDirectoryOptions ( $ basename , $ filenames , $ options ) { $ name_list = [ ] ; $ results = [ ] ; // We need to know the path to the file so we can check if it's a directory. foreach ( $ filenames as $ file ) { $ name_list [ ] = [ 'name' => $ file , 'path' => implode ( DIRECTORY_SEPARATOR , [ rtrim ( $ basename , DIRECTORY_SEPARATOR ) , ltrim ( $ file , DIRECTORY_SEPARATOR ) ] ) , ] ; } foreach ( $ name_list as $ name_and_path ) { $ name = $ name_and_path [ 'name' ] ; $ isdir = is_dir ( $ name_and_path [ 'path' ] ) ; if ( ( $ options & GLOB_MARK ) && $ isdir ) { $ name = rtrim ( $ name , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; } if ( $ options & GLOB_ONLYDIR ) { if ( $ isdir ) { $ results [ ] = $ name ; } } else { $ results [ ] = $ name ; } } return $ results ; }
Perform glob directory actions on a list of files.

@param string $basename The directory name for the glob results.
@param array $filenames An array of file name strings.
@param int $options The options passed to glob().
@return array An array of results that match the glob() options.
Perform glob directory actions on a list of files .