Mike
Mike

Reputation: 1

Create the page with hyperlinks from txt file

I would like to know if you can create a php page, by importing data from a txt file, let me explain better (I hope) I have a .txt file which is composed as follows:

Link 1
http://www.example.com/index1.php
Link 2
http://www.example.com/index2.php
Link 3
http://www.example.com/index3.php

is possible with a php script to create a page in php so

<a href="http://www.example.com/index1.php">Link 1</a>
<a href="http://www.example.com/index2.php">Link 2</a>
<a href="http://www.example.com/index3.php">Link 3</a>

how can I do,thank you

Upvotes: 0

Views: 1074

Answers (1)

diavolic
diavolic

Reputation: 722

<?php 
   $links = File("put path to file here");
   foreach ($links as $key=>$val)
      if ($key%2) $link_name = $val;
        else
           print "<a href='$val'>$link_name</a>";

?>

Upvotes: 1

Related Questions