这是从数组中删除重复的 strlen 项的最简单方法吗?我做了很多与此类似的任务的编程,这就是为什么我问,如果我做得太复杂,或者这是否是最简单的方法。
$usedlength = array();
$no_duplicate_filesizes_in_here = array();
foreach ($files as $file) {
foreach ($usedlength as $length) {
if (strlen($file) == $length) continue 2;
}
$usedlength[] = strlen($file);
$no_duplicate_filesizes_in_here[] = $file;
}
$files = $no_duplicate_filesizes_in_here;