How can the file() function be used effectively in PHP for reading the contents of a text file?
The file() function in PHP can be used effectively to read the contents of a text file by passing the file path as a parameter to the function. This function reads the file into an array, where each element of the array represents a line from the text file. By using this function, you can easily access and manipulate the contents of the text file in your PHP script.
$file_path = "example.txt";
$file_contents = file($file_path);
foreach($file_contents as $line){
echo $line . "<br>";
}