note 75156 added to function.readdir

From: Date: Tue, 15 May 2007 15:36:55 +0000
Subject: note 75156 added to function.readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-126618@lists.php.net to get a copy of this message
<?php // Sample function to recursively return all files within a directory. // http://www.pgregg.com/projects/php/code/recursive_readdir.phps Function listdir($start_dir='.') { $files = array(); if (is_dir($start_dir)) { $fh = opendir($start_dir); while (($file = readdir($fh)) !== false) { # loop through the files, skipping . and .., and recursing if necessary if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue; $filepath = $start_dir . '/' . $file; if ( is_dir($filepath) ) $files = array_merge($files, listdir($filepath)); else array_push($files, $filepath); } closedir($fh); } else { # false if the function was called with an invalid non-directory argument $files = false; } return $files; } $files = listdir('.'); print_r($files); ?> ---- Server IP: 194.145.210.3 Probable Submitter: 81.144.219.162 ---- Manual Page -- http://www.php.net/manual/en/function.readdir.php Edit -- https://master.php.net/note/edit/75156 Del: integrated -- https://master.php.net/note/delete/75156/integrated Del: useless -- https://master.php.net/note/delete/75156/useless Del: bad code -- https://master.php.net/note/delete/75156/bad+code Del: spam -- https://master.php.net/note/delete/75156/spam Del: non-english -- https://master.php.net/note/delete/75156/non-english Del: in docs -- https://master.php.net/note/delete/75156/in+docs Del: other reasons-- https://master.php.net/note/delete/75156 Reject -- https://master.php.net/note/reject/75156 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126618) next »