Jump to content

glob issue


carlosx2

Recommended Posts

Well this is not really a glob issue.

 

What i would like to do is write a little code that tells me if an mime type is there or not.

 

at the moment i have

if ($flv_movie_count >= 3){ ?>

 

this little if check how many files there are in the folder. I know that is there are more than 2 files it are flv files. But i would like to use a statement that checks if the the file is flv or not. Then run script or go to a else. I have looked around, but i just don't know which function i should be using and how to apply it.

 

Maybe some one can help me.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/203544-glob-issue/
Share on other sites

Could use DirectoryIterator()

then do something with the $fileinfo like explode it using the "." as the delimiter then try to match the file... of course this assumes that . is never part of the name of the file for this to work.

 

<?php
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
    if ($fileinfo->isFile()) {
     $file_is = $fileinfo->getFilename();
     $pieces = explode(".", $file_is);
     // $pieces[0]; // name
     // $pieces[1]; // the suffix
     if($pieces[1] == "flv"){ echo $pieces;}
               else{echo "Not an flv file.";}


    }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/203544-glob-issue/#findComment-1066297
Share on other sites

carlosx2, could you explain what you really want a little more clearly? The topic title, first line and later comments are a confusing muddle of nothing much at all.  Do you really want some code to tell you if a MIME type is there (where?), or do you want to check file extensions like gwolgamott suggested, or do you want to check if a folder contains more than 2 files, or...?

Link to comment
https://forums.phpfreaks.com/topic/203544-glob-issue/#findComment-1066355
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.