Reading files into PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marco J.L

    Reading files into PHP

    Hello,

    how can I read files into PHP. I can make a listing of a directory, but
    reading the file content into the PHP goes wrong.

    ==== script ==========
    <?php
    $handle=opendir ('nieuws');
    while (false!==($file = readdir($handle ))) {
    if ($file != "." && $file != "..") {
    $fp = fopen($file,"rb ");
    fpassthru($fp);
    fclose($fp);
    echo $fp;
    echo "<HR>";
    }
    }
    closedir($handl e);
    ?>

    ===========

    Thanx,

    Marco J.L.


  • NC

    #2
    Re: Reading files into PHP

    Marco J.L wrote:[color=blue]
    >
    > how can I read files into PHP. I can make a listing of a directory,
    > but reading the file content into the PHP goes wrong.[/color]

    Try this:

    $handle = opendir('nieuws ');
    while (false!==($file = readdir($handle ))) {
    if ($file != "." && $file != "..") {
    readfile($file) ;
    echo "<HR>";
    }
    }
    closedir($handl e);

    Cheers,
    NC

    Comment

    • Jacob Atzen

      #3
      Re: Reading files into PHP

      On 2005-04-06, Marco J.L <luyendyk@yahoo .com.news> wrote:[color=blue]
      > how can I read files into PHP. I can make a listing of a directory, but
      > reading the file content into the PHP goes wrong.[/color]

      file_get_conten ts() - check the manual.

      --
      Cheers
      - Jacob Atzen

      Comment

      • Chung Leong

        #4
        Re: Reading files into PHP


        "Marco J.L" <luyendyk@yahoo .com.news> wrote in message
        news:d31i23$pu$ 1@reader10.wxs. nl...[color=blue]
        > Hello,
        >
        > how can I read files into PHP. I can make a listing of a directory, but
        > reading the file content into the PHP goes wrong.
        >
        > ==== script ==========
        > <?php
        > $handle=opendir ('nieuws');
        > while (false!==($file = readdir($handle ))) {
        > if ($file != "." && $file != "..") {
        > $fp = fopen($file,"rb ");
        > fpassthru($fp);
        > fclose($fp);
        > echo $fp;
        > echo "<HR>";
        > }
        > }
        > closedir($handl e);
        > ?>
        >
        > ===========
        >
        > Thanx,
        >
        > Marco J.L.
        >
        >[/color]

        array_map('read file', glob('nieuws/*.*'));


        Comment

        Working...