Dooling Posted October 25, 2007 Report Share Posted October 25, 2007 Pieņemsim direktorijā ir vairāki faili, bet man vajag nolasīt tikai vienu no tiek, kas ir pievienots pēdējais (failiem nosaukumi ir augošā secībā, t.i. 1,2,3,4,5,6,7,8,9,10,11 utt). if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); } Ar šo piemēru man izvada visu direktorijas saturu, bet kā, lai panāk man vēlamo? Link to comment Share on other sites More sharing options...
bubu Posted October 25, 2007 Report Share Posted October 25, 2007 Pa punktiem: 1) salasi visus failu vārdus masīvā, 2) paņem pēdējo masīva elementu un atver to failu. Link to comment Share on other sites More sharing options...
Delfins Posted October 25, 2007 Report Share Posted October 25, 2007 bubu, nebija tā kā vēl jāsasortē ? The filenames are returned in the order in which they are stored by the filesystem PS: katrā ziņā - notestēt vajag. Link to comment Share on other sites More sharing options...
Dooling Posted October 25, 2007 Author Report Share Posted October 25, 2007 Paldies! Tagad viss strādā kā vajag ;) Link to comment Share on other sites More sharing options...
Grey_Wolf Posted October 25, 2007 Report Share Posted October 25, 2007 nebija tā kā vēl jāsasortē ? ne pedejais ieraksts buus arii pedejais pievienotais... Link to comment Share on other sites More sharing options...
PheliX Posted October 25, 2007 Report Share Posted October 25, 2007 ne pedejais ieraksts buus arii pedejais pievienotais... Tas būs true tikai ja neko nedzēsīs no tās direktorijas Link to comment Share on other sites More sharing options...
bubu Posted October 25, 2007 Report Share Posted October 25, 2007 Ok, jā - piemirsu: 2.5) sasortē masīvu pēc failu izveidošanas datuma. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted October 26, 2007 Report Share Posted October 26, 2007 Tas būs true tikai ja neko nedzēsīs no tās direktorijas hmm.. ja ja izdzees tad ... A vispar viss atkariigs no OS... "Fraja" skjit ka bija Po.... --- bubu --> ari par to iedomajos...(precizak buss peec pedejas modefikacijas... ;( ) + nevienmer ir verts ielsiit masivaa... dazreiz var to pasakumu nedaudz piekaast..... parlasiit visus failus gan nakas.... bet nesivit vinjus.... tik panjemt pedejo true... (maza RAM optimizacija...) Link to comment Share on other sites More sharing options...
Recommended Posts