PHP, 84 62个字节
$t=array_map(filesize,$g=glob('*'));asort($t);echo$g[key($t)];
由于以假设当前目录中没有文件夹的方式更新了问题,因此我能够删除文件检查内容并将其删除。
这是我的旧答案:
$t=array_map(filesize,$g=array_filter(glob('*'),is_file));asort($t);echo$g[key($t)];
这是我能做的最好的。也许有一种更好的方式我会丢失。
$t=array_map( # visit each array element and...
filesize, # map each filename to its filesize...
$g=array_filter( # using an array of...
glob('*'), # all files and directories...
is_file # filtered by files...
) #
); #
asort($t); # sort the array of filesizes, then...
echo$g[key($t)]; # print element from the array of files using the first key of the sorted array as an index