2015-04-23 86 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