Read text file into array and output : Text File Read « File Directory « PHP






Read text file into array and output

<?php
   $userfile= file_get_contents("./text.txt");

   // Place each line of $userfile into array
   $users = explode("\n",$userfile);

   foreach ($users as $user) {
      list($name, $email) = explode(" ", $user);
      echo "<a href=\"mailto:$email\">$name/a> <br />";
   }
?>


           
       








Related examples in the same category

1.Read text file with format
2.Read file content with only one command
3.Display XML file
4.Read in and perform operations on a file line by line
5.Read text file into an array in one function
6.Try to open a text file
7.Viewing the Source of a Document