2012-10-13 63 views
-1

我想使用preg_match_all從線程獲取磁鏈接,然後使用第一個磁鏈接。preg_match_all磁鐵鏈接

我嘗試了很多模式,但沒有任何工作。

$uris = array(); 
preg_match_all('\'http://magnet:?\'', $post, $uris); 
foreach ($uris[0] as $href) { 
////////////////////////////// 
$magnetUri = $href; 
break; 
} 
+1

因爲磁鐵鏈接最多沒有'http://'在其中。 – hjpotter92

+0

閱讀關於什麼URI(以及URN和URL)的含義。 –

+0

@ TheDOCTORfromTARDIS即使沒有'http://'也不起作用。 –

回答

1

我以前使用preg_match呼叫以匹配TTH磁體。或許,這會爲你工作:

preg_match('/magnet:\?xt=urn:tree:tiger:(?P<tth>\w+)/', $rows['msg'], $matchTTH); 

Ofcourse,我存儲每個磁體的TTH在這種情況下,你可以使用任何其他的these hashes

+0

的帖子中獲得它我試圖編輯它爲BTIH,但每次給我空陣列。如何實現這一目標? –

+0

有什麼幫助嗎? –

+0

@DZZOO這裏有一個鏈接:http://codepad.viper-7.com/lu7L0g – hjpotter92