note 106685 modified in function.readdir by thiago

From: Date: Tue, 29 Nov 2011 13:03:48 +0000
Subject: note 106685 modified in function.readdir by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184766@lists.php.net to get a copy of this message
A function i made to read the array and check if the file exist in an array great for testing against a db to find files in a folder that arent already logged <?php function read_dir($dir, $array = array()){ $dh = opendir($dir); $files = array(); while (($file = readdir($dh)) !== false) { $flag = false; if($file !== '.' && $file !== '..' && !in_array($file, $array)) { $files[] = $file; } } return $files; } ?> --was-- A function i made to read the array and check if the file exist in an array great for testing against a db to find files in a folder that arent already logged function read_dir($dir, $array = array()){ $dh = opendir($dir); $files = array(); while (($file = readdir($dh)) !== false) { $flag = false; if($file !== '.' && $file !== '..' && !in_array($file, $array)) { $files[] = $file; } } return $files; } http://php.net/manual/en/function.readdir.php

« previous php.notes (#184766) next »