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?
Use parse_url
. You want the host
component. Once you have that, you can remove the www.
if it exists.
精彩评论