<?php
/*
Source: https://www.w3schools.com/php/php_file_open.asp
The feof() function checks if the "end-of-file" (EOF) has been reached.
The feof() function is useful for looping through data of unknown length.
The example below reads the "x.txt" file line by line, until end-of-file is reached:
Modes Description:
r Open a file for read only. File pointer starts at the beginning of the file
w Open a file for write only. Erases the contents of the file or creates a new file if it doesn't exist. File pointer starts at the beginning of the file
a Open a file for write only. The existing data in file is preserved. File pointer starts at the end of the file. Creates a new file if the file doesn't exist
x Creates a new file for write only. Returns FALSE and an error if file already exists
r+ Open a file for read/write. File pointer starts at the beginning of the file
w+ Open a file for read/write. Erases the contents of the file or creates a new file if it doesn't exist. File pointer starts at the beginning of the file
a+ Open a file for read/write. The existing data in file is preserved. File pointer starts at the end of the file. Creates a new file if the file doesn't exist
x+ Creates a new file for read/write. Returns FALSE and an error if file already exists
*/
$fname = ".Mortgage_Statement.pdf";
$myfile = fopen("read_text_file_fopen_feof_fgets.txt", "r") or die("Unable to open file!");
// Output one line until end-of-file
while(!feof($myfile)) {
$date = fgets($myfile);
// print_r (explode(",",$date));
$y = (explode("
",$date));
$y = (explode(",",$date));
//print_r($y);
//echo count($y);
//var_dump($y);
//$arr_length = count($y);
//for($i=0;$i < $arr_length;$i++)
//{
// $z = $y[$i] . " " . $y[$i];
// echo date('Ymd', strtotime($z)). $fname . "
";
//}
$z = $y[0] . " " . $y[1];
echo date('Ymd', strtotime($z)). $fname . "
";
}
fclose($myfile);
?>