Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8894265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:27:08+00:00 2026-06-14T23:27:08+00:00

Possible Duplicate: How do I auto convert an url into a hyper link in

  • 0

Possible Duplicate:
How do I auto convert an url into a hyper link in PHP?

Let’s say, I have an textfield on my website, where the user can enter anything he wants to.
If the user enters a url, I would like to add code to this url in the background. Therefor I would need logic in order to recognize the url.

Example
The user enters a text:

Please visit me at my website: http://www.mywebsite.org

I would like to change the code in the background to something like this:

Please visit me at my website: <a href="http://www.companywebsite.com/redirect.php?http://www.mywebsite.org">http://www.mywebsite.org</a>

How is it possible to change that link after the text has been submitted?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:27:09+00:00Added an answer on June 14, 2026 at 11:27 pm
    <?php
    
    // The Regular Expression filter
    $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
    
    // The Text you want to filter for urls
    $text = "The text you want to filter goes here. http://google.com";
    
    // Check if there is a url in the text
    if(preg_match($reg_exUrl, $text, $url)) {
    
           // make the urls hyper links
           echo preg_replace($reg_exUrl, "<a href="{$url[0]}">{$url[0]}</a> ", $text);
    
    } else {
    
           // if no urls in the text just return the text
           echo $text;
    
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Auto-size dynamic text to fill fixed size container. Let's say i have
Possible Duplicate: Mobile site - force landscape only / no auto-rotate I have seen
Possible Duplicate: Auto-Initializing C# Lists I have a list of integers that has a
Possible Duplicate: Push-Notification Badge auto increment. I have implemented Push Notification for my iPhone
Possible Duplicate: Why does ASP.NET auto-generated .designer code have the incorrect type? On my
Possible Duplicate: Auto Submitting a form (cURL) I have a form which submits to
Possible Duplicate: How much is too much with C++0x auto keyword Have we (as
Possible Duplicate: How do you give a C# Auto-Property a default value? I have
Possible Duplicate: Auto refresh eclipse project upon folder update I have been working with
Possible Duplicate: Access Auto-Increment Value During INSERT INTO Statement I would like to generate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.