eregi_replace problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm having problems getting my head around eregi_replace. What I want to do
is allow users to enter links to their sites in a simple guest book. The
links can take either of 2 formats:-

[url] [/url]
which would display ' ' as the link text


[url=,htm ]click here[/url] which would
display 'click here' as a clickable link.

The first one I've managed to get working but I can't get my head around
the 2nd. Can anyone point be in the right direction please. I've looked and
looked at but just can't make any sense of it :(

Re: eregi_replace problem

$url = '[url= ]click here[/url]';
$pattern = array('/\[\/url\]/i', '/\[url=/i', '/\]/i');
$replace = array('</a>', '<a href="', '">');

print preg_replace($pattern, $replace, $url);

//note: preg_* and not eregi_* used

Re: eregi_replace problem

On Sun, 02 Mar 2008 09:00:31 +0100, noname wrote:

Quoted text here. Click to load it

Thanks, that worked a treat :)

Site Timeline