<?php $fontList = array(); $fontLocation = WWW_ROOT."img/brief/graphic/font_style"; if(file_exists($fontLocation) && is_dir($fontLocation)) { $dirs = array_diff( scandir( $fontLocation ), Array( ".", ".." ) ); foreach($dirs as $fileName) { /* ENDS WITH .jpg */ if(is_file($fontLocation."/".$fileName) && preg_match("/\.jpg$/i", $fileName)) { echo "MATCH: ".$fileName."<BR>"; } /* STARTS WITH 'godhuli' */ if(is_file($fontLocation."/".$fileName) && preg_match("/^godhuli/i", $fileName)) { echo "MATCH: ".$fileName."<BR>"; } } } $list = array_filter($list, "__private_checkPregReplace54131256"); function __private_checkPregReplace54131256($input) { if(preg_match("/\./i", $input)) { return true; } return false; } ?>
Showing posts with label read file from location. Show all posts
Showing posts with label read file from location. Show all posts
Friday, February 8, 2013
php get file list from location ends or start with some string preg_match
Subscribe to:
Posts (Atom)