$table="<P>户型南北通透,视野光线好,总价超低,周边配套齐全,购物方便,出行也比较方便,未来升值空间大。
</P><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716248936506.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716198283399.JPG'/>";现需:得到src=后面的值,并用| 连起来 ,应该得到    http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG|http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG|http://0791.8ff.cn/upload/broker/user/432/pic/201101141716198283399.JPG
这如何实现,在线等

解决方案 »

  1.   

    先preg_match_all("/src='(.*?)'/",$str,$matched);
    然后echo implode("|",$matched);
      

  2.   

    多谢,不过,楼上的有点不对
    我只需src=''中的值,应该得到三个图片的url,
      

  3.   


    <?php
    $str="<P>户型南北通透,视野光线好,总价超低,周边配套齐全,购物方便,出行也比较方便,未来升值空间大。
    </P><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716248936506.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716198283399.JPG'/>";preg_match_all("/src='(.*?)'/",$str,$matched);echo implode("<br>",$matched['1']);
      

  4.   

    <?php
    $str="<P>户型南北通透,视野光线好,总价超低,周边配套齐全,购物方便,出行也比较方便,未来升值空间大。
    </P><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716248936506.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716198283399.JPG'/>";preg_match_all("/src='(.*?)'/",$str,$matched);echo implode("|",$matched['1']);
      

  5.   


    $table="<P>户型南北通透,视野光线好,总价超低,周边配套齐全,购物方便,出行也比较方便,未来升值空间大。
    </P><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG'/><br><br><img width='500' height='336'  src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716248936506.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716198283399.JPG'/>";$result=array();
    preg_match_all('/http.*?JPG/',$table,$result);
    echo implode('|',$result[0]);
      

  6.   

    使用以下代码可以正确匹配到src里的内容<?php$str="<P>户型南北通透,视野光线好,总价超低,周边配套齐全,购物方便,出行也比较方便,未来升值空间大。
    </P><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716298364890.JPG'/><br><br><img width='500' height='336'src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716248936506.JPG'/><br><br><img width='500' height='336' src='http://0791.8ff.cn/upload/broker/user/432/pic/201101141716198283399.JPG'/>";$arr=array();preg_match_all("/src='(.*?)'/",$str,$arr);
    print_r($arr[1]);
      

  7.   

    function get_img_src($table)
    {   $content    =   stripslashes($table);     
    preg_match_all("/<img.+src=(('|\")(.+)('|\"))/Uis",$content,$out);  
    foreach($out[1] as $t)

    $t = str_replace("'","",$t);
    $t = str_replace("'","",$t);
      $tables.=$t.'|';
    }
    $tables_arr=explode("|",$tables);
    $str=' \r';
    foreach($tables_arr as $value)
    {
    if($value!='' && $value!=NULL )
    {
    $str.=" \r  \r " ;
    }
    }
    return $str;
    }