The example in this article describes how PHP reads file content into an array. Share it with everyone for your reference. The specific analysis is as follows:
In PHP, files can be read into an array through the file() function. The elements in the array are each line of the file. The file() function uses "n" to split the file by line and save it to the array, so each of the arrays The elements all end with "n", we can remove them through the rtrim() function
?
3 4 5
|
$lines = file("/tmp/file.txt");
foreach ($lines as $line) {
$line = rtrim($line);
print("$linen"); |