Results 1 to 2 of 2

Thread: Opening multiple files in loop using php

  1. #1
    mmeister3 is offline New Member: Posts Will Be Moderated
    Join Date
    Jun 2011
    Posts
    1

    Opening multiple files in loop using php

    I started taking a web development class and im having trouble running a loop that opens multiple files.
    The files are label as so:

    movie_review0.txt
    movie_review1.txt
    movie_review2.txt
    movie_review3.txt
    movie_review4.txt

    We have to write a loop not knowing how many files there are in the folder. Does anyone have any suggestions? I've tried using a while loop but I dont think I have the syntax correct. Thanks

  2. #2
    Join Date
    Jun 2007
    Posts
    295
    You could do something like this:
    PHP Code:
    $directory "/path/to/txtfiles/";
    if (
    glob("$directory*.txt") != false)
    {
     
    $numfiles count(glob("$directory*.txt"));
     for (
    $i=0$i $numfiles$i++) {
          echo 
    'movie_review' $i '.txt<br />';
      }


Similar Threads

  1. linking multiple .js files
    By rickyric in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 16 Sep 2010, 10:27 AM
  2. Edit multiple files
    By roozak in forum General Questions
    Replies: 1
    Last Post: 18 Nov 2006, 03:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •