Return to Snippet

Revision: 33348
at October 8, 2010 03:31 by chicagowebmanagement


Initial Code
<?php 
//locate file for collection
$userfile= file_get_contents("links.txt");


/* this user file (links.txt) is simply a series of URLS, each on one line like so:
www.xxxxxxx.org
www.yyymmmzzz.com
www.someotherurl.com

*/

//explode each line of hte links.txt file directly into an array
$links = explode("\n",$userfile);

//sort($links) or shuffle($links) or whatever this array
sort($links);

//output the array for display. 
foreach ($links as $text) {
echo '<a href="http://' . $text .'">' . $text . '</a><br />' . " \n";
}

?>

Initial URL

                                

Initial Description
This is a simple 'text to array for output' script that I've used a few times for my clients. Hope you like!

Initial Title
Explode Text File of URLS into HTML links

Initial Tags
php, file, array, text

Initial Language
PHP