php read text file into array

Solutions on MaxInterview for php read text file into array by the best coders in the world

showing results for - "php read text file into array"
Mika
30 May 2017
1//php read a text file into an array
2//each item in the array is a line in the text file
3//file.txt looks like this:
4//hello
5//testing
6//text
7//end file.txt (the file doesn't include the // marks
8$file = file("http://example.com/file/file.txt");
9echo $file[0]; //prints hello
10echo $file[1]; //prints testing
11echo $file[2]; //prints text