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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:22:05+00:00 2026-06-17T01:22:05+00:00

Possible Duplicate: Getting domain name without TLD So I have a Web site I

  • 0

Possible Duplicate:
Getting domain name without TLD

So I have a Web site I am trying to work on. In the URL there is info and I want to parse it out and use it to make a db call to mysql:

http://www.relevant-info.org/home.html

I want to take the Url put it into a string.

Then I want to only get ‘relevant-info’ out of the url.

$webaddress = $_SERVER["SERVER_NAME"];
$parts = parse_url($webaddress);
$url = substr($Parts, 4, -4);

^ i am using that and I got the ip address (it is a centos 5.8 lamp) on a VM i am testing this, so in short this seams to work good so far 🙂

  • 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-17T01:22:07+00:00Added an answer on June 17, 2026 at 1:22 am

    Credits to Relentless

    You can easily find it with the PHP parse-url function: parse_url

    Example usage: If you want to get ‘relevant-info’, a PHP 5.4 valid code could look like:

    $Url = substr(parse_url("http://www.relevant-info.org/home.html")[1], 4, -4);
    

    Output

    relevant-info

    For PHP 5.3 and less

    $Parts = parse_url("http://www.relevant-info.org/home.html");
    $Url = substr($Parts, 4, -4);
    

    In future situtations, if you do not have fancy functions like parse-url, you can use Regex or use str_split

    Remember that str_split requires less resources

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: # in url getting ignored in php 5.2 I have following link
Possible Duplicate: Getting jQueryUi Autocomplete to work with jQueryMobile Is there a out of
Possible Duplicate: Getting the name of the current executing method Is there a way
Possible Duplicate: Getting jQuery-inserted DOM elements without requerying for element after insertion Is there
Possible Duplicate: Getting Cross-thread operation not valid Cross-thread operation not valid I am trying
Possible Duplicate: Getting a FILE* from a std::fstream Is there a way to obtain
Possible Duplicate: Getting the minimum of two values in sql I'm trying to get
Possible Duplicate: Getting the class name from a static method in Java When you
Possible Duplicate: Getting a value from HttpServletRequest.getRemoteUser() in Tomcat without modifying application Short version:
Possible Duplicate: Getting a random value from a JavaScript array OK, so I have

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.