note 100717 added to function.glob

From: Date: Tue, 02 Nov 2010 12:12:06 +0000
Subject: note 100717 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-173681@lists.php.net to get a copy of this message
Alternative glob function with case insensitive pattern handling: function globi($directorySource, $caseinsensitive = false) { $input = explode('/', $directorySource); $count = count($input); if($count >= 2) { $i = 0; while(++$i < $count) { if(is_dir(implode('/',$directory).'/'.$input[$i-1])) { $directory[] = $input[$i-1]; } } $directorySourceF = join('/',$directory); } else { $directorySourceF = './'; } $db = opendir($directorySourceF); $output = array(); while(($file = readdir($db))!= false) { $filepattern = str_replace('*.', '.*\.', $input[$count-1]); if(preg_match("/".$filepattern."/".($caseinsensitive ? 'i' : ''), $file) && is_file($directorySourceF.'/'.$file)) { $output[] = $file; } } @closedir($db); return $output; } ---- Server IP: 69.147.83.197 Probable Submitter: 213.217.108.74 ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- https://master.php.net/note/edit/100717 Del: integrated -- https://master.php.net/note/delete/100717/integrated Del: useless -- https://master.php.net/note/delete/100717/useless Del: bad code -- https://master.php.net/note/delete/100717/bad+code Del: spam -- https://master.php.net/note/delete/100717/spam Del: non-english -- https://master.php.net/note/delete/100717/non-english Del: in docs -- https://master.php.net/note/delete/100717/in+docs Del: other reasons-- https://master.php.net/note/delete/100717 Reject -- https://master.php.net/note/reject/100717 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173681) next »