Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

I've asked a question where I want to get the domain name of an url like if the url is the the domain will be However they point me the previous questions where it has been asked something else or there is no correct answer.

The question: How to get the domain name from an url with PHP?

share|improve this question
You got off to a bad start by editing out the auto inserted "duplicate question" text – ChrisF Nov 25 '11 at 15:12
The original question wanted to go from | -> and you want to go from | -> That is the same question, I'm not sure why you feel otherwise. I also don't really see a question in this post, are you asking for an extended explanation of why it was closed, or..? – Tim Stone Nov 25 '11 at 15:21
Just in case you're wondering why you're being downvoted here: it's fine to post here if you think your question was wrongly close, however your title accuses others of not reading your question when in fact it was you who did not read the question linked as duplicate. That generally does not go down well. – Shawn Chin Nov 25 '11 at 15:50
@ShawnChin, So you are saying that if a question was asked in the past and did not get a right answer then you should not ask it again? As I said here "or there is no correct answer" at the pointed question. – ilhan Nov 25 '11 at 16:50
I'm saying that either you haven't read the other questions well enough, or you haven't explained yourself well enough. Either way, most readers will interpret your current question such that you'll end up getting similar answers to the other questions. – Shawn Chin Nov 25 '11 at 16:55

Looks like a dup to me. The linked question contain answers that can solve your problem (and a bit more).

One of the answers uses parse_url and str_ireplace to make the following transformation: ->  -> ->       ->          

which is similar to what you're asking, no?

P.S. consider using preg_replace("/^www\./", "", $domain) instead of str_ireplace to avoid inadvertently replacing too much e.g. for cases like "".

From your updates, I can just about guess what you're trying to achieve, i.e. truncate domain name to a single subdomain after the public suffix (effective TLD). I've given you a reopen vote but you'll have to do a lot better to convince others. Simply listing some examples with no explanation is hardly a question.

Had you spent as much effort on your question as you did fighting your case here and in the comments, you'd probably have gotten a sensible solution by now.

P.S. If I my second attempt at understanding your question is not too far off, then you might find this blog post useful. In short, regdom provide libraries in several languages (including PHP) that can do that for you.

share|improve this answer
Why you are upvotin!? It is wrong! It doesn't handle !!! – ilhan Nov 25 '11 at 16:46
This answers the question as you have currently framed it. How should be handled? Your question says nothing of it. Try editing your question with more details and it might have a chance of getting reopened. – Shawn Chin Nov 25 '11 at 16:57
I didn't frame it, examples and are still there. – ilhan Nov 25 '11 at 17:14
I see you've made another attempt at the question. I've added an answer. – Shawn Chin Nov 25 '11 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .