Activity Stream
48,167 MEMBERS
61043 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Member

    Default [PHP] Create Filelist of files with Specific Extensions

    Hey Guys ,

    Any idea how to create a filelist of a location via php with files with a specific extension :

    E.g : .avi

    let's say the location is "/location/folder1/"

    Inside i have : Folderx , folderz , file1.avi , file2.avi , file2.rar

    Now i want to create a filelist of that folder using only files with .avi ext .





    viruz99 Reviewed by viruz99 on . [PHP] Create Filelist of files with Specific Extensions Hey Guys , Any idea how to create a filelist of a location via php with files with a specific extension : E.g : .avi let's say the location is "/location/folder1/" Inside i have : Folderx , folderz , file1.avi , file2.avi , file2.rar Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    PHP Code: 
    function read_dir($dir) {
        
    $handle opendir ($dir);
        while (
    false !== ($f readdir ($handle))){
            if (
    $f != "."){
                if (
    $f != ".."){
                    
    $file=$dir.$f;
                    if(
    is_file($file)) {
                        
    $ext strtolower(substr($filestrrpos($file'.') + 1));
                        if(
    $ext == 'avi') echo $file.'<br />';
                    
                    }
                }
            }
        }
    }

    read_dir('full_path_to_dir'); 

  4.     
    #3
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    PHP Code: 
    <?php

    $folder 
    = array(); // Creates a array for use later

    foreach (glob("/location/folder1/*.avi") as $thefolder) { // Use for each to go through and get each folder & file in the given directory
        
    If (is_file($thefolder)) { // We only want to get files so we are making sure that we are adding a file and not a directory.
            
    $folder[] = $thefolder// Adds the file to the array created
        
    }
    }

    print_r($folder); // Print out the list for debug

    ?>
    You can specify the filename search pattern in glob

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 5 IE9 extensions you should know about
    By CyberPrince in forum News & Current Events
    Replies: 0
    Last Post: 8th Nov 2011, 01:06 AM
  2. Adding specific words to all TXT files at the same time
    By astalavistia in forum Web Development Area
    Replies: 6
    Last Post: 24th Apr 2011, 11:57 AM
  3. Replies: 2
    Last Post: 23rd Feb 2011, 02:06 PM
  4. create dummy file with specific size in php
    By techdaemon in forum Webmaster Discussion
    Replies: 0
    Last Post: 28th Sep 2010, 12:55 AM
  5. Replies: 7
    Last Post: 26th Jul 2010, 08:33 AM

Tags for this Thread

BE SOCIAL