[英]Extract image with preg_match_all Function
我的preg_match_all有問題,這是我的PHPfile中的一個函數:
function get_images ($content){
preg_match_all ('#\\[img\\](.+?)\\[/img\\]#ie', $content, $preg_array);
if (count ($preg_array[1]) != 0){
foreach ($preg_array[1] as $item){
if ($this->reset_url($_SERVER['HTTP_HOST'])!=$this->reset_url($item)){
if (!(in_array ($item, $this->images))){
$this->images[] = $item;
continue;
}
}
}
}
}
使用該代碼,我只能從簡單的[img] [/ img]標簽提取圖像,例如:
[img]http://www.domain.com/image.jpg[/img]
我不能將img標簽與align一起使用,例如:
[img=left]http://www.domain.com/image.jpg[/img]
我如何解決此功能以同時使用兩個圖像標簽?
#\[img(:?.*)?\](.*?)\[/img\]#
這將忽略[img=foo]
,僅獲取源信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.