Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

file upload - How can I save a directory tree to an array in PHP? -


i'm trying take directory structure:

top     folder1         file1     folder2         file1         file2 

and save array like:

array (     'folder1' => array('file1'),     'folder2' => array('file1', 'file2') ) 

this way, can resuse tree throughout site. i've been playing around code it's still not doing want:

private function get_tree() {     $uploads  = __relpath__ . ds . 'public' . ds . 'uploads';     $iterator = new recursiveiteratoriterator(new recursivedirectoryiterator($uploads), recursiveiteratoriterator::self_first);     $output   = array();      foreach($iterator $file)     {         $relativepath = str_replace($uploads . ds, '', $file);          if ($file->isdir())         {             if (!in_array($relativepath, $output))                 $output[$relativepath] = array();         }     }      return $output; } 

im horrible recursive functions. managed come this..not sure it's you're looking for

function tree($path, $top) {     $ignore = array('cgi-bin', '.', '..' );      $handle = opendir($path);         while( ($file = readdir($handle)) !== false ) {          if( !in_array( $file, $ignore ) ){                           if( is_dir("$path/$file") ) {                 $top[$file] = @ tree("$path/$file", $top[$file]);             } else {                 $top[] = $file;             }         }      }      closedir( $handle );     return $top; } 

assuming directory tree is

alt text

it outputs

array (     [a] => array         (             [aa] => array                 (                     [0] => aa.txt                 )          )      [b] => array         (             [0] => bb.txt         )      [c] => array         (             [0] => cc.txt         )  ) 

but, take break , go watch eclipse happens every 300 , years. dont want 'no' when kids, grandkids, great-grandkids ask 'did know alive when winter solstice eclipse occurred?? did see it?????"

:)


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -