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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:20:27+00:00 2026-06-03T06:20:27+00:00

I have a site and I would need to get one pages URL with

  • 0

I have a site and I would need to get one pages URL with PHP. The URL might be something www.mydomain.com/thestringineed/ or it can www.mydomain.com/thestringineed?data=1 or it can be www.mydomain.com/ss/thestringineed

So it’s always the last string but I dont want to get anything after ?

  • 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-03T06:20:29+00:00Added an answer on June 3, 2026 at 6:20 am

    You will use the parse_url function, then look at the path portion of the return.
    like this:

    $url='www.mydomain.com/thestringineed?data=1';
    $components=parse_url($url);
    
    //$mystring= end(explode('/',$components['path']));
    
    // I realized after this answer had sat here for about 3 years that there was 
    //a mistake in the above line
    // It would only give the last directory, so if there were extra directories in the path, it would fail. Here's the solution:
    $mystring=str_replace( reset(explode('/',$components['path'])),'',$components['path']); //This is to remove the domain from the beginning of the path.
    
    // In my testing, I found that if the scheme (http://, https://, ...) is present, the path does not include 
    //the domain. (it's available on it's own as ['host']) In that case it's just  
    // $mystring=$components['path']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically i have a classic vhost with: ServerName www.site.com ServerAlias site.com I would like
I have one web site in IIS, and I would like to have version
I would like to have my site’s logo shown in the icon area of
I have a site that supports localization. I would like to be able to
I would like to ask you: Imagine that you have a site and there
I'm building a HTML template for my site and would like to have a
I have a web site and a web service and I would like to
Hiiii I have a jQtouch site in dev and i would like to use
Hey guys, I have developed a small site that i would like to embed
i would like to have a block on my drupal site(latest version) that displays

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.