note 86425 added to function.glob

From: Date: Sat, 18 Oct 2008 01:18:19 +0000
Subject: note 86425 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-145464@lists.php.net to get a copy of this message
I lost hours looking for the solution for this problem. glob() wasn't eating up my directory names (stuff like "foobar[]"), and I searched online for some hours, I tried preg_quote to no avail. I finally found the proper way to escape stuff in glob() in an obscure Python mailing list: <?php preg_replace('/(\*|\?|\[)/', '[$1]', $dir_path); ?> If you want to add a directory path before your pattern, you should do it like this: <?php glob(preg_replace('/(\*|\?|\[)/', '[$1]', $dir_path).'*.txt'); ?> preg_quote WILL NOT work in all cases (if any). ---- Server IP: 194.8.30.16 Probable Submitter: 85.138.96.35 ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- https://master.php.net/note/edit/86425 Del: integrated -- https://master.php.net/note/delete/86425/integrated Del: useless -- https://master.php.net/note/delete/86425/useless Del: bad code -- https://master.php.net/note/delete/86425/bad+code Del: spam -- https://master.php.net/note/delete/86425/spam Del: non-english -- https://master.php.net/note/delete/86425/non-english Del: in docs -- https://master.php.net/note/delete/86425/in+docs Del: other reasons-- https://master.php.net/note/delete/86425 Reject -- https://master.php.net/note/reject/86425 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145464) next »