I am trying to make a script that reads urls from a text file.
The first line of the text file will contain the text that should be displayed on the webpage. The second line of the file will contain the actual link to the website. I have include the script so far. Thanks for the help.


Text File

First web page
www.firstpage.com
Second page
www.secondlink.com

VB Code:
  1. <?php
  2.  
  3. function ConvertToLinks ($vert)
  4.  
  5. {
  6.  
  7. $vert = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1<a href="http://\\2">\\2</a>', $vert);           
  8.                      
  9.                      
  10. return $vert;
  11. }
  12.  
  13.  
  14.  
  15.  
  16. #***************************************
  17. #Program start
  18. #
  19. #
  20. #***************************************
  21.  
  22. $filename = "text.txt";
  23. $flepointer = fopen ($filename, "r") or die ("Could not open the file");
  24. $contents = fread ($flepointer, filesize ($filename));
  25. fclose($flepointer);
  26. echo ConvertToLinks($contents);
  27.  
  28.  
  29.  
  30. ?>