| Autor | Zpráva | ||
|---|---|---|---|
| Pes Profil * |
#1 · Zasláno: 12. 12. 2009, 15:01:31
<?php
class AdrStr
{
public $path;
public $order;
public $filtr;
protected $struktura = array();
protected $adr = array();
protected $file = array();
private $hn;
public function __construct($path = "ulozene/")
{
$this->path = $path;
$this->nacti();
}
public function nacti()
{
$this->hn = opendir($this->path);
while(false!==($file = readdir($this->hn)))
{
if(!in_array($file, array(".", "..")))
$this->struktura[$file] = filemtime($this->path.$file);
}
closedir($this->hn);
}
public function serad(&$s) // $this->order prijima name_asc|name_desc|time_asc|time_desc
{
if($this->order)
switch($this->order)
{
case "name_asc": ksort($s); break;
case "name_desc": krsort($s); break;
case "time_asc": asort($s); break;
case "time_desc": arsort($s); break;
}
}
public function oddel()
{
foreach($this->struktura as $file => $q)
{
if(is_dir($this->path.$file))
$this->adr[] = $file;
else
$this->file[] = $file;
}
}
public function execute()
{
$this->serad($this->struktura);
$this->oddel();
}
public function return_adr()
{
return $this->adr;
}
public function return_file()
{
return $this->file;
}
}
$vr = new AdrStr();
$vr->order = "time_desc";
$vr->execute();
echo "<pre>";
print_r($vr->return_adr());
print_r($vr->return_file());
echo "</pre>";
?>použil jsem tedy tento kód, ovšem zde se mě vypisují všechny informace, jak udělám (protože se nevyznám v oop) jak udělám aby se mi jich vypsalo posledních 7 ? |
||
| Alphard Profil |
#2 · Zasláno: 12. 12. 2009, 17:02:48 · Upravil/a: Alphard
Chcete soubory nebo adresáře?
$pocet = 7;
$soubory = $vr->return_file();
$k = $pocet <= count($soubory) ? $pocet : count($soubory);
for ($i = 0; $i < $k; $i++)
{
echo $soubory[$i]."<br>\n";
} |
||
| Pes Profil * |
#3 · Zasláno: 14. 12. 2009, 17:24:20
soubory, které obsahuje ten adresář ... tudiž například fotografie uložené ve složce /ulozene/
|
||
|
Časová prodleva: 16 let
|
|||
0