Показать сообщение отдельно

  #3  
Старый 07.04.2009, 19:01
NOmeR1
Познавший АНТИЧАТ
Регистрация: 02.06.2006
Сообщений: 1,187
Провел на форуме:
6023777

Репутация: 2642


По умолчанию

Код:
<form method="POST">
Погрешность <input type="text" name="p" value="<?=($_POST['p']!=null?htmlspecialchars($_POST['p']):"100")?>" size="5"> кб<br>
<input type="submit" value="go go go">
</form><br>
<?php
if($_POST['p'] != null) {
	$p = (int)$_POST['p'];
	$dir = 'images/';
	if (is_dir($dir)) {
		if ($dh = opendir($dir)) {
			while (($file = readdir($dh)) !== false) {
				$all_files[] = array($dir.$file, filesize($dir.$file));
			}
			closedir($dh);
		}
	}
	$o = 0;
	unset($all_files[0]);
	unset($all_files[1]);
	foreach($all_files as $i => $file1) {
		$true = false;
		foreach($all_files as $j => $file2) {
			if($i!=$j&&abs($file1[1]-$file2[1])<=$p*1024) {
				$array[$o][] = array($file2[0], $file2[1]);
				$true = true;
			}
		}
		if($true === true) {
			$array[$o][] = array($file1[0], $file1[1]);
			sort($array[$o++]);
		}
	}
	$sorten = array();
	foreach($array as $o => $g) {
		if(!in_array($g, $sorten, true)) $sorten[] = $g;
	}
	if(sizeof($array)>0) {
		foreach($sorten as $group) {
			foreach($group as $file) {
				echo $file[0].' '.round($file[1]/1024).' кб<br>';
			}
			echo '<hr>';
		}
	} else {
		echo 'Нет таких';
	}
}
?>
 
Ответить с цитированием