Tag Archives: read file

PHP – read CSV file into an array and create files from an array

<?php $file = fopen(‘files.csv’, ‘r’); while (($line = fgetcsv($file)) !== FALSE) {  foreach ($line as $value) {    echo($value.'<br>’); $HTMLFile = fopen($value.’.html’,”w”); $TextFile = fopen($value.’.txt’,”w”); fwrite($HTMLFile,$value); fwrite($TextFile,$value);  }  } fclose($file); ?>

Posted in PHP/MySQL | Tagged , , , , | Comments Off on PHP – read CSV file into an array and create files from an array

PHP – read text file and get contents

<?php $myfile = fopen(“file-to-read.txt”, “r”) or die(“Unable to open file!”); // Output one line until end-of-file while(!feof($myfile)) { echo fgets($myfile) . “<br>”; } fclose($myfile); ?>

Posted in PHP/MySQL | Tagged , | Comments Off on PHP – read text file and get contents