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 6709315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:51:59+00:00 2026-05-26T07:51:59+00:00

I have a website were users enters articles and their reference(like wikipedia). The reference

  • 0

I have a website were users enters articles and their reference(like wikipedia). The reference which were saved in the database includes both web address and non web addresses.Currently i am hyper linking the script using google’s search?q and its working properly.

     echo("<br><a rel=nofollow  target=_blank href='http://www.google.com/search?q=".urlencode($row['ref'])."' class=art>$row[ref]</a>");

i want to know whether its possible to automatically detect my reference as a web address or not .if it is a web address then when users click to the hyperlink it goes directly to that website and if not it should hyperlink to google search.

eg:

if user enters this link as reference.hyper link should be to this web address

      http://www.washingtonpost.com/sports/capitals
      or
      www.washingtonpost.com/sports/capitals
      or
      washingtonpost.com/sports/capitals

or if the user enters reference as below

     washingtonpost+sports+capitals

it should go to googles search?q

advance thanks for your help

  • 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-05-26T07:51:59+00:00Added an answer on May 26, 2026 at 7:51 am

    You would use a regular expresion to see if it is a link and make it a link. Regular expression also makes sure it is valid syntax for a link.

     $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 = "http://www.google.com"; #The text you want to filter goes here
     // 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 '<a href="http://www.google.com/search?q=',urlencode($text),'">',$text,'</a>';
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website which requires users to enter their corporate network username and
I have a website where users can upload their files; these are stored on
I have a internal website that users log into. This data is saved as
I have a website that lets users comment on books and articles, and the
I have a website where users can enter their Twitter Login information. This site
For my website, I need to have a way for users to enter their
I have a website that prompt the users to enter serial number for a
Say you have a website for users to search for hotel rooms for rent.
We have developed our website(Business users website) in .net Framework 2.0 Our client us
We have a simple registration form for our website users where we only require

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.