eregi_replace problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mad Hatter

    eregi_replace problem

    Hi

    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:-


    which would display 'http://www.nowhere.co. uk/apage.htm' as the link text

    or

    click here 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 php.net but just can't make any sense of it :(
  • noname

    #2
    Re: eregi_replace problem

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

    print preg_replace($p attern, $replace, $url);

    //note: preg_* and not eregi_* used

    Comment

    • Mad Hatter

      #3
      Re: eregi_replace problem

      On Sun, 02 Mar 2008 09:00:31 +0100, noname wrote:
      $url = 'click here';
      $pattern = array('/\[\/url\]/i', '/\[url=/i', '/\]/i');
      $replace = array('</a>', '<a href="', '">');
      >
      print preg_replace($p attern, $replace, $url);
      >
      //note: preg_* and not eregi_* used
      Thanks, that worked a treat :)

      Comment

      Working...