58 users online (0 members and 58 guests)  


  Results 1 to 3 of 3

Related

  1. Title Page help needed    Forum: Search Engine Optimization - SEO - Forum
    Replies: 9
  2. Parse partial directory name    Forum: CGI Perl Forum
    Replies: 1
  3. Replies: 5
  4. Replies: 0
  5. read files in multiple directories?    Forum: CGI Perl Forum
    Replies: 2
  1. #1
    Cooleyvol's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2007
    Posts
    6

    PHP file to parse the title of multiple files in the same directory needed

    I have a directory that I'd like a listing of the <title> of the newly created files.
    They are all html files with the <title> tag in them.
    I wondered if there's code already written or if someone could write code so that I could select the creation date of the files I want parsed and it would return to me the titles of all the files in that directory, either in txt or html format.
    Ideally, I would take the output of this file and use it to create a scoreboard ticker for an online fantasy league that I run.
    The contents of the folder I'm speaking of can be found at gridiron-glory.net/BoxScores
    When new files are created (twice a week), I'd like a script to run that would output the title of the newest files. The title of each file is that game's score.
    Thanks.

  2. #2
    flann's Avatar
    New User

    Status
    Offline
    Join Date
    May 2007
    Posts
    18

    Re: PHP file to parse the title of multiple files in the same directory needed

    instead of storing the files in html, try storing them in xml. Then you can use all of the built in tools for xml parsing and would make this task a whole lot easier.

  3. #3
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: PHP file to parse the title of multiple files in the same directory needed

    Haven't got time to knock up a demo just now, but roughly speaking you'd need to:
    1. Open the file for reading with fopen()
    2. Find the <title> tag with strpos()
    3. Add 7 to this value to get the start of the title itself
    4. Find the </title> tag with strpos()
    5. Subtract the start value of the title to get the length
    6. Extract the title string with substr()
    7. Close the file to prevent any clashes later

    Should fix it ... pop back here with any questions.



Tags for this Thread