All4172 Posted July 10, 2006 Share Posted July 10, 2006 I have the following script that list the files in a dir (I use php 4 so can't use scandir).[code]<?phpif ($handle = opendir('/home/public_html/dir')) { echo "Directory handle"; // List all the files while (false !== ($file = readdir($handle))) { echo "$file\n"; echo "<P>"; } closedir($handle);}?> [/code]How would I go about adding something saying, only display files that end in say .php or .xml ect? Quote Link to comment https://forums.phpfreaks.com/topic/14230-how-to-search-for-partic-article-type-ie-php-xml/ Share on other sites More sharing options...
ShogunWarrior Posted July 10, 2006 Share Posted July 10, 2006 if(preg_match('/(\.php|\.xml)$/i',$file)){ //It is either PHP or XML.}To add more/less just add a pipe [b]|[/b], dot [b]\.[/b] and the extension, e.g: [b]\.html[/b] Quote Link to comment https://forums.phpfreaks.com/topic/14230-how-to-search-for-partic-article-type-ie-php-xml/#findComment-55855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.