Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    Exclamation Preg_replace: rename URL to custom title

    I have a function with a button, that fetches a javascript pop-up with an input where people can post a hyperlink to another website. That works, but now, I want to give the hyperlink a different name, other than the linkname itself. The users would have to get a new popup after the first one and set the custom name for a url to show that as a link.

    PHP Code:
    $message preg_replace("'\(http://(.*)\)'Ui","<a target=blank_ href=\"http\\3://\\1\">http\\3://\\1</a>",$message); 
    This is what I want to happen:


    So you can see that 1 2 and 3 are links. On my site, you can see the links too, but the full `http://` path of the link is shown and not a custom name. How can I make this happen?

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Thanked 790 Times in 788 Posts
    Why do you need two pop ups? Ask the user to give you a url AND a short name for it. One pop up.

    Your preg_replace don't seam to work. What happens if https://www.google.com/ is submitted?

    Your display is some thing like this:
    <a href="productpagelink.htm">Widget<img src="images/arrv_blue_2.gif"></a>


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts