我需要对保存在文本文件中的url列表检索'host'。下面的代码一次处理1个url。
$bits = parse_url("http://me:secret@example.com/cgi-bin/board?user=fred");
echo $bits['host'];
要提取
example1.com
example2.com
example2.com
类似于
foreach(file('your_file') as $h){
$bits = parse_url($h);
echo $bits['host'];
}