PHP array question

Soldato
Joined
2 Dec 2005
Posts
5,514
Location
Herts
Simple array question. I want to have a page of links. This page reads an external file to get the links, creates an array, then prints them in a certain fashion. The aim of this is so links can be added as simple text, quickly and easily into the external page without knowing any code.

For example, the external page may look like
Code:
http://www.firstlink.com, A link somewhere
http://www.second.com, The second link
and the php somehow manages to echo
Code:
<a href="http://www.firstlink.com">A link somewhere</a><br />
<a href="http://www.second.com">The second link</a><br />

How? :)
 
Cheers guys. Bit cryptic, but ended up with this, which works:
Code:
<?php
$thelinks = file('thelinks.php');
foreach ($thelinks as $a)
{
	$links = explode(", ",$a);
	echo "<a href=\"{$links[0]}\">{$links[1]}</a><br />";
}
?>
Where does htmlentities come into this? Doesn't seem necessary. Cheers.
 
Last edited:
I agree rob.

paulsheffII - fair point. Should be ok here though, just a simple thing to make it easier for the client to stick up his own links.
 
Seem to be spending a lot of time in HG&P 'Serker, you not got much else on? No forums to moderate...?

:p

(I can derail my thread if I want to :D )
 
Back
Top Bottom