Blitz Posted August 29, 2005 Report Share Posted August 29, 2005 Varbut kads var palidzet. Man mapes "tree" sastav apmeram no 500 mapeem, un katraa ir kadas 20 fotografijas. Man vajag nolasit katras fotografijas filename un salidzinat to ar db esoso info. Izmantojot readdir varu opereet tikai iar 1majaa limeni esosajiem failiem, bet ne tiem kas atrodas zem subfolders. Varbut kadam jau ir kads gatavs skripts, kas nolasa ari subfolderu saturu vai ari kaads zin kaa var saglabat failaa MSDOS komandas dir /s info? Paldies jau ieprieks :) Link to comment Share on other sites More sharing options...
bubu Posted August 29, 2005 Report Share Posted August 29, 2005 kas par muļķībām, ka readdir lasa tika vienu līmeni! Cik vien līmeņus gribi! Piemērs no manuāļa: <?php if ($handle = opendir('mape/apakshmape')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); }?> Link to comment Share on other sites More sharing options...
Blitz Posted August 29, 2005 Author Report Share Posted August 29, 2005 Nu jaa bet no subfolderiem taa pat neko ar sito ara dabut nevar. Piemeram man ir viena mape ar 500 apaksmapeem, zem katras apaksmapes 20 faili, kaa lai piedabuun vinu izvilkt informaciju arii no taas. 500x taksh nerakstishu ieprieks mineto skriptu... :huh: Link to comment Share on other sites More sharing options...
smarty Posted August 29, 2005 Report Share Posted August 29, 2005 izmanto rekursiju, ibio Link to comment Share on other sites More sharing options...
bubu Posted August 29, 2005 Report Share Posted August 29, 2005 Kādu rekursiju vēl, smarty.. Te tak divi līmeņi tikai. Par ciklu iekš cikla neesi iedomājies, Blitz? Link to comment Share on other sites More sharing options...
Blitz Posted August 30, 2005 Author Report Share Posted August 30, 2005 Man ir nosaciti divos limenos, jo var ari paradities vairaki... Butu loti laipni ja varetu seit iemest kadu rekursijas piemeru, ludzu.... ;) Link to comment Share on other sites More sharing options...
bubu Posted August 30, 2005 Report Share Posted August 30, 2005 (edited) Ja divos līmeņos, tad šādi (tas ir pseidokods, kā pārrakstīt uz php izdomāsi): foreach($mape in $mapju_saraksts) { foreach($fails in $mape) { // apstrādā $fails } } Ja rekursiju, tad: function mapes_apstraade($mape) { foreach($fails in $mape) { if (ir_direktorija($fails)) { mapes_apstraade("$mape/$fails"); } else { // ir fails // faila apstrāde } } } mapes_apstraade("baazes_mape"); // bez / beigās Edited August 30, 2005 by bubu Link to comment Share on other sites More sharing options...
Blitz Posted August 30, 2005 Author Report Share Posted August 30, 2005 o beidzot kaut kas kustas, thenks :) Link to comment Share on other sites More sharing options...
Recommended Posts