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

  #10  
Старый 05.11.2007, 17:54
MegaDeth
Участник форума
Регистрация: 08.11.2006
Сообщений: 208
С нами: 10266046

Репутация: 184
По умолчанию

RedBull@12, да все норм я сделал с графикой даже )
посути, перед заполнением массива проверяется существование уже имеющаегося ключа и 2 раза не посчитает его счетчик =)))
PHP код:
<?php
$m
=array();
$r=0;
$st=0;
$img=imagecreatetruecolor(500,500);
$color=imagecolorallocate($img,255,255,255);

function 
GetPlos($mas)
{
GLOBAL 
$m,$r,$st,$img,$color;
$res=(($mas[3]-$mas[1])*($mas[2]-$mas[0]));
//echo $res.'<br>';
$st=$st+$res;
$color=imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));
for (
$i=$mas[0];$i<$mas[2];$i++)
{
for (
$j=$mas[1];$j<$mas[3];$j++)
{
//if (!isset($m[$i][$j])) {
if (!isset($m[$i][$j])) {
$m[$i][$j]=true$r++; 
imagesetpixel($img,$i+100,-$j+100,$color);


}
}

}
return 
$m;
}

$mfile=file('prams.txt');
$arr=array();
for (
$i=0;$i<count($mfile);$i++)
{
$mas=explode(' ',$mfile[$i]);
GetPlos($mas);


header('Content-Type: image/png');
imagepng($img);
//header('Content-Type: text/html');
echo $r."<br> Общая площадь ".$st;
?>
 
Ответить с цитированием