Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

74
Views
Get only domain name

i want only domain name without sub domain and path URL.

Example :

URL loading in browser : https://www.example.com/something. I want only example.com

I tried echo $_SERVER['HTTP_HOST']; and echo $_SERVER['SERVER_NAME']; but the output is www.example.com but it want example.com as output.

What to use?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would make a check for the existing of "www." in the beginning of the string, and if the string starts with "www." I would remove it.

Example:

$domain = substr($_SERVER['SERVER_NAME'],0,4) === 'www.' ? substr($_SERVER['SERVER_NAME'],4) : $_SERVER['SERVER_NAME'];
echo $domain;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!