2015-04-23 56 views
0

由於PHPBB有它自己的調用內置圖片的方式,我有POST_TEXT這樣的事情僅獲得圖像URL

test content [img:32acu135]http://mywebsite.com.pk/wp-content/uploads/2012/10/some-thing-3.jpg[/img:32acu135] 
數據庫

, 有什麼辦法,我可以打電話第一在內容的圖像,可能是使用preg_match_all或正則表達式..

+0

你的輸出是什麼? –

+0

圖片網址http://mywebsite.com/wp-content/uploads/2012/10/something-3.jpg –

回答

0

我會去一個正則表達式像

\[img.+?\](.*)\[\/img.+?\] 

,並採取捕獲組

PHP示例

$re = "/\\[img.+?\\](.*)\\[\\/img.+?\\]/"; 
$str = "[img:32acu135]http://mywebsite.com.pk/wp-content/uploads/2012/10/some-thing-3.jpg[/img:32acu135]"; 

preg_match($re, $str, $matches); 

print($matches[1]); 

結果:

HTTP : // mywebsite . COM . PK /可溼性粉劑內容/上傳/ 2012/10 /一些-事情-3- . JPG