note 76499 deleted from function.glob by sobak

From: Date: Thu, 01 Dec 2016 06:33:54 +0000
Subject: note 76499 deleted from function.glob by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207804@lists.php.net to get a copy of this message
Note Submitter: Sam Yong - hellclanner at live [dot] com ---- An alternative to this glob function. Like what edogs [at] dogsempire.com said, opendir should be faster than glob. I have not tested timing for this function but it works perfectly for me on my PHP v5.2.2 server. <?php $_foo ='/server/public_html/path/'; function s_glob($dir){ $files = array(); if(is_dir($dir)){ if($dh=opendir($dir)){ while(($file = readdir($dh)) !== false){ $files[]=$dir.$file; }} } return $files; } print_r(s_glob($_foo)); ?> This function returns an empty array if no files are found in the directory or the path specified is not a directory.

« previous php.notes (#207804) next »