note 76499 added to function.glob

From: Date: Wed, 18 Jul 2007 12:31:50 +0000
Subject: note 76499 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-128685@lists.php.net to get a copy of this message
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. ---- Server IP: 202.79.178.90 Probable Submitter: 202.156.13.1 (proxied: 222.165.28.11) ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- https://master.php.net/note/edit/76499 Del: integrated -- https://master.php.net/note/delete/76499/integrated Del: useless -- https://master.php.net/note/delete/76499/useless Del: bad code -- https://master.php.net/note/delete/76499/bad+code Del: spam -- https://master.php.net/note/delete/76499/spam Del: non-english -- https://master.php.net/note/delete/76499/non-english Del: in docs -- https://master.php.net/note/delete/76499/in+docs Del: other reasons-- https://master.php.net/note/delete/76499 Reject -- https://master.php.net/note/reject/76499 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128685) next »