What are the advantages of using file_get_contents over file for reading text files in PHP for comparison purposes?

When reading text files in PHP, using file_get_contents() is often preferred over file() because it returns the file contents as a string, making it easier to manipulate and work with. Additionally, file_get_contents() is more concise and efficient compared to file(), which returns an array of lines from the file.

// Using file_get_contents to read a text file
$file_contents = file_get_contents('example.txt');
echo $file_contents;