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? 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] 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
Archived
This topic is now archived and is closed to further replies.