In php, how can I open and read in a text file and make each line of type string and an element in an array?
My plan is then to use a foreach
to travel through the array and use in_array()
to look for words in the contents of the file.
In php, how can I open and read in a text file and make each line of type string and an element in an array?
My plan is then to use a foreach
to travel through the array and use in_array()
to look for words in the contents of the file.
Use file()
:
$lines = file('path/to/file');
foreach($lines as $line)
{
//enjoy
}