Tutorial Read/Write Files

by in , 0

Append to a file

function fileWrite($file, $message) {
  fwrite(fopen($file, 'a'), $message . "\n");
}

Read and display entire file

function fileRead($file){
   $lines = file($file);
   foreach ($lines as $line_num => $line) {
      echo  $line,  '</br>';
   }
}

Leave a Reply