2014-05-18 85 views
1

我在下面的文本文件中列出了一個網址列表。我想提取獨特的url模式,例如,從網址池中提取獨特的網址

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 
+0

創建一個數組,並使用任何PHP的給定唯一分揀方法 – Ohgodwhy

回答

1

加載到一個數組中,並使其獨特:

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