Php 使用preg_match_all函数提取图像

Php 使用preg_match_all函数提取图像,php,image,Php,Image,我对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_u

我对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=left]http://www.domain.com/image.jpg[/img]
我无法将img标记与对齐一起使用,例如:

[img]http://www.domain.com/image.jpg[/img]
[img=left]http://www.domain.com/image.jpg[/img]
如何修复此函数以同时使用两个图像标记?

使用此函数

preg_match_all ('#\\[img.*\\](.+?)\\[/img\\]#ie', $content, $preg_array);
用这个

preg_match_all ('#\\[img.*\\](.+?)\\[/img\\]#ie', $content, $preg_array);

这将忽略
[img=foo]
中的任何内容,只获取源信息

这将忽略
[img=foo]
中的任何内容,只获取源信息