How can you read file, like text file line by line and get contents to and array using php? This can be using “FILE_IGNORE_NEW_LINES”.Here is a tested example to read text file line by line and create an array.

This is your text file named Student_details.txt

Read file line by line.

This is a another method to read file line by line into an array.

Additional: