Script to open folders and files

Discussion in 'PHP' started by dfsweb, Mar 23, 2006.

  1. #1
    Hi guys,
    I am just writing some code that will go through an entire folder (all sub-folders and files in it) and will open each file and search it for a search phrase. Basically, I have around 7 folders inside one folder and all these folders have txt files and I want to create a programme that will open all these files and search for the phrase. I can do everything BUT ....

    I just need to know if there is a command that:
    1. Gives me a list of all folders in a folder
    2. Gives me a list of all files in a folder

    I don't need all the code, I can manage the rest once I get these commands.
    Regards,
    dfsweb
     
    dfsweb, Mar 23, 2006 IP
  2. saidev

    saidev Well-Known Member

    Messages:
    328
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    140
    #2
    try opendir() and readdir() and is_dir();
    Some good examples at php.net and search for opendir
     
    saidev, Mar 23, 2006 IP
  3. dfsweb

    dfsweb Active Member

    Messages:
    1,587
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    88
    #3
    Thanks for that. I'll try it out over the weekend and see if it works.
    dfsweb
     
    dfsweb, Mar 24, 2006 IP