Ask a question about obtaining a domain name from a website ~ -Php Tutorial

Source: Internet
Author: User
Ask a question about getting a domain name from a website ~~~~~ I need to do this now. & nbsp; obtain its domain name from a bunch of URLs. for example, some URLs are saved in the database & nbsp; & nbsp; community. csdn. netExpertPostNew. asp? Room303 & nb ~~~~~
I need to do this now and get its domain name from a bunch of URLs.
For example, some URLs are stored in the database.
Http://community.csdn.net/Expert/PostNew.asp? Room = 303
Http://www.baidu.com? Lm = 0 & si = & rn = 10 & ie = gb2312
Http://www.taobao.com/browse/11/
...
To get his domain name from these URLs
Http://community.csdn.net
Http://www.baidu.com
Http://www.taobao.com


Expert guidance

------ Solution --------------------
String cutting
------ Solution --------------------
Take http: // to the next content.
------ Solution --------------------
Parse_url function
------ Solution --------------------
Cut "/"
Note:
Http://www.baidu.com
Split into three parts
That is
1. http:
2. empty string
3.www.baidu.com
------ Solution --------------------
$ S = 'http: // community.csdn.net/Expert/PostNew.asp? Room = 303
Http://www.baidu.com? Lm = 0 & si = & rn = 10 & ie = gb2312
Http://www.taobao.com/browse/11 ';
Preg_match_all ('/(http :\/\/.*?) \/.*? /I ', $ s, $ m );
Print_r ($ m [1]);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.