Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    recognizing a url in php form

    Basically i need advice on how to recognize a url. Say a user fills in info for a news page and half way through the news info he types http://www.cnn.com (into a textbox) Basically i want to know how the server will post this as a link rather then as a long string of text that other users can't click

    Edit: Notice in my post it automatically creates the link to cnn website without me having to type some code.

  • #2
    New Coder
    Join Date
    May 2003
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do a search on php.net for preg_replace or ereg_replace, you will find the code that does this in the comments of other users.
    cpCommerce - Finally a template based open-source e-commerce solution

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do somthing like below

    Code:
    $txt = "how to recognize a url. Say a user fills in info for a news page and half HTTPS://www.cnn.com way through the news info he types http://www.cnn.com";
    $txt=preg_replace("//(https?:\/\/[^ ]*)/si"," <a href=\"$1\">$1</a> ",$txt);
    echo $txt;
    Last edited by sidney; 05-11-2004 at 05:47 PM.


  •  

    Posting Permissions

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