Source Code:
(back to article)
<?php // Open file "file.txt" in write mode $file = fopen("file.txt", "w"); // Write three lines of text to the file fwrite($file, "Line 1\nLine 2\nLine 3"); // Close the file fclose($file); // Read the contents of the file into an array, where each line is an element in the array $lines = file("file.txt"); // Loop through the array and output each line foreach ($lines as $line) { // Output the line with a line break echo $line . "\r\n"; }
Result:
Report an issue