Read a text file into an array

Read a text file into an array

<?php
   $file = file_get_contents(“test.txt”);

   // Place the contents of test.txt in an array
   $contents = explode(“\n”,$file);

   foreach ($contents as $content)
   {
      echo “$content”;
   }
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*