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

  • Home
  • SEARCH
  • 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 8349999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:10:49+00:00 2026-06-09T08:10:49+00:00

I have a form that inputs url dynamically, the user may input www.stack.com or

  • 0

I have a form that inputs url

dynamically, the user may input

www.stack.com  or
www.stack.com/overflow  or
http://www.stack.com  or
http://www.stack.com/overflow

how can I prevent to insert the duplicate entry to my database?

I’ve tried these

$url = (input url)

$search = str_replace("http://www.", "", $url);
$search = str_replace("http://", "", $url);
$search = str_replace("www.", "", $url);
$search = str_replace("/", "", $url);

at the last $search, I wanted to remove all the following character after “/” including “/”
what does follow?

  • 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-09T08:10:50+00:00Added an answer on June 9, 2026 at 8:10 am

    For some who will stuck with the same question and drop here, here’s the complete code for this

    if((strpos($url, 'http://')  !== false) || (strpos($url, 'https://')  !== false)) 
    {   $host = parse_url($url, PHP_URL_HOST); 
        if (strpos($url, 'www.') !== false)
            $host = str_replace('www.', '', $host);
        if (strpos($host, '/') !== false)
        {   $str = explode("/", $host);
            $host = $str[0];
        }
    }
    
    else if (strpos($url, 'www.') !== false)
    {   $host = str_replace('www.', '', $url);
        if (strpos($host, '/') !== false)
        {   $str = explode("/", $host);
            $host = $str[0];
        }
    
    }
    else if (strpos($url, '/') !== false)
        {   $str = explode("/", $url);
            $host = $str[0];
        }
    
    else $host = $url;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a form that accepts some input from a user that may
I have a login form that has Username and password as inputs from user
I have a dynamic form that users can add/delete sets of input fields. I
I have this form where a user can input tags (tag_list input) like Graphic
I have a form with inputs using this naming convetion: <input class=xxlarge name=note[url] id=url
I have a form that takes the following inputs: Name: IBM Surface(in m^2): 9
So i have a simple form that takes a few inputs (two text and
I have a form that uses jquery to generate rows of input fields these
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a form that I pre-populate with test data though jQuery. $('INPUT[name=subscription.FirstName]').val('Jef'); but

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.