Menu
I’m making a basic news section, with a script to add news and another to read it, which will be embedded in an HTML page eventually. I’m fairly new to PHP, and I’ve got an issue with URLs in the content.
The URL is added to the file ok, the file looks like this –
[code]
12.07.05|Simon|Let’s try a hyperlink test <a href=”http://www.msn.com”>for MSN</a>
and the PHP code that reads and displays the file is this –
[code]
<?php
$data = file(‘news.txt’);
$data = array_reverse($data);
foreach($data as $element) {
$element = trim($element);
$element = preg_replace(‘/(http|ftp)+(s)?:(//)((w|.)+)(/)?(S+)?/i’, ‘<a href=”