从网址池中提取唯一的网址

时间:2014-05-18 17:22:57

标签: php

我在文本文件中有一个网址列表,如下所示。我想提取独特的网址模式,例如,

http://abi.sitename.org/aaa/4468488240.html
http://sss.sitename.org/aaa/4460627166.html
http://abo.sitename.org/aaa/4462471529.html
http://aby.sitename.org/aaa/4467495766.html
http://abz.sitename.org/aaa/4419425396.html

可以用php完成吗?请建议。

http://abi.sitename.org/aaa/4468488240.html
http://abi.sitename.org/aaa/4462744311.html
http://abi.sitename.org/aaa/4419879366.html
http://sss.sitename.org/aaa/4460627166.html
http://sss.sitename.org/aaa/4456802709.html
http://sss.sitename.org/aaa/4425163148.html
http://abo.sitename.org/aaa/4462471529.html
http://abo.sitename.org/aaa/4469067299.html
http://abo.sitename.org/aaa/4453989838.html
http://aby.sitename.org/aaa/4467495766.html
http://aby.sitename.org/aaa/4454567635.html
http://aby.sitename.org/aaa/4466553375.html
http://abz.sitename.org/aaa/4457930202.html
http://abz.sitename.org/aaa/4419425396.html
http://abz.sitename.org/aaa/4455620614.html
http://abc.sitename.org/aaa/4459281546.html
http://abc.sitename.org/aaa/4458913064.html

1 个答案:

答案 0 :(得分:1)

加载到数组中并使其唯一:

$lines = array_unique(file('/path/to/file.txt'));