0

Possible Duplicate:
how do i parse url php

I have strings in the format of 'http://www.example.com/', some of them have the trailing slash, and other don't, how would I extract 'example.com' from them?

Community
  • 1
  • 1
PaperChase
  • 1,557
  • 4
  • 18
  • 23

1 Answers1

2

Use parse_url. You want the host component. Once you have that, you can remove the www. if it exists.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539