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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:46:06+00:00 2026-06-04T04:46:06+00:00

If I had a url such as www.example.com/test/example/product.html How would I be able to

  • 0

If I had a url such as www.example.com/test/example/product.html

How would I be able to get just the test part(so the top level)

I understand you would use $_SERVER['REQUEST_URI'] and maybe substr or trim

But I am unsure of how to do this, thank you!

  • 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-04T04:46:07+00:00Added an answer on June 4, 2026 at 4:46 am

    Split the string into an array with explode, and then take the part you need.

    $whatINeed = explode('/', $_SERVER['REQUEST_URI']);
    $whatINeed = $whatINeed[1];
    

    If you use PHP 5.4, you can do $whatINeed = explode('/', $_SERVER['REQUEST_URI'])[1];

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

Sidebar

Related Questions

See the bullets on this blog post: http://www.nielsbrinch.com/managing-expectation-management/ I have had to change to
For example, I have an URL that looks for an image like this: http://example.com/img/foo.png
Before I decide to use DetailView , I had a url redirect using this
When I first start one of my Wordpress blogs, I had the permanent URL
I had a quick question about Django URL configuration, and I guess REGEX as
I wrote this ISAPI filter to rewrite the URL because we had some sites
I recently added some url re-writing to my web application and had to added
I'm facing a problem with Regex... I had to match sharepoint URL.. I need
I never had such a problem and I'm pretty puzzled: function delete_post(id) { var
I have a site set up on www.domain.com , the site can authenticate users

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.