<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4417.0">
<TITLE>RE: [Wolves] quick php question</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Sorry, spotted a small mistake.<BR>
<BR>
$output .= '<li>'.auto_link(rtrim($line)).'</li>';<BR>
<BR>
Should be<BR>
<BR>
$output .= '<li>'.auto_link(rtrim($url)).'</li>';<BR>
<BR>
Luke<BR>
<BR>
________________________________<BR>
<BR>
From: Luke Redpath<BR>
Sent: 19 August 2005 18:53<BR>
To: Wolverhampton Linux User Group<BR>
Subject: RE: [Wolves] quick php question<BR>
<BR>
<BR>
<BR>
Hi,<BR>
<BR>
As Jono said, you might have a quicker response in future posting to a dedicated PHP list, but I can help you so I'll give you a quick solution.<BR>
<BR>
I'm assuming you have a source file that looks like this:<BR>
<BR>
--source.txt--<BR>
<A HREF="http://www.google.com">http://www.google.com</A><BR>
<A HREF="http://www.amazon.co.uk">http://www.amazon.co.uk</A><BR>
<A HREF="http://www.bbc.co.uk">http://www.bbc.co.uk</A><BR>
Etc...<BR>
--source.txt--<BR>
<BR>
Just a simple list of URLs. Now, I'm not a big fan of procedural programming, but instead of giving you a full-blown OOP solution, I'll just give you some simple functions that do the job. Be sure to include link_reader_functions.php into the script you are working on.<BR>
<BR>
--link_reader_functions.php--<BR>
function auto_link($url) {<BR>
return "<a href=\"$url\">$url</a>";<BR>
}<BR>
<BR>
function link_list($source) {<BR>
$output = '<ul>';<BR>
foreach(file($source) as $line_num => $url) {<BR>
$output .= '<li>'.auto_link(rtrim($line)).'</li>';<BR>
}<BR>
$output .= '</ul>';<BR>
return $output;<BR>
}<BR>
--link_reader_functions.php--<BR>
<BR>
Simply use it like this:<BR>
<BR>
--example.php--<BR>
<?php<BR>
require 'link_reader_functions.php';<BR>
?><BR>
<BR>
<h1>My Links</h1><BR>
<BR>
<?php echo link_list('source.txt') ?><BR>
--example.php--<BR>
<BR>
That will render a nice unordered html list of links, which you can then format as required using CSS. I've not tested it but it should work. E-mail me off-list if you have a problem with the script.<BR>
<BR>
HTH<BR>
<BR>
Luke<BR>
<BR>
-----Original Message-----<BR>
From: Re-LoaD [<A HREF="mailto:reload@brum2600.net">mailto:reload@brum2600.net</A>]<BR>
Sent: 19 August 2005 16:01<BR>
To: Wolverhampton Linux User Group<BR>
Subject: [Wolves] quick php question<BR>
<BR>
Hello World,<BR>
<BR>
quick question for all you php guru's :)<BR>
<BR>
I need to read a pain text file that contains some url's and display the file on a web page containing clickable links were it finds a url in the text file.<BR>
<BR>
I can got it sort of working but there must be an easier way than splitting and array by /[space]<BR>
<BR>
thanks as always<BR>
<BR>
Re-<BR>
<BR>
<BR>
<BR>
---<BR>
Hand Tested Antivirus: Outbound message clean.<BR>
Tested on: 19/08/2005 16:00:55<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
_______________________________________________<BR>
Wolves LUG mailing list<BR>
Homepage: <A HREF="http://www.wolveslug.org.uk/">http://www.wolveslug.org.uk/</A><BR>
Mailing list: Wolves@mailman.lug.org.uk<BR>
Mailing list home: <A HREF="http://mailman.lug.org.uk/mailman/listinfo/wolves">http://mailman.lug.org.uk/mailman/listinfo/wolves</A><BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>