<?
$str='<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<img src="0.jpg" width=59 height=59>
<img src="1.jpg" width=59 height=59>
<img src="1.jpg" width=59 height=59>
<img src="2.jpg" width=59 height=59>
<img src="4.jpg" width=59 height=59>
<img src="3.jpg" width=59 height=59>
</BODY>';preg_match_all("'<img src=\"([0-9]+)\.'",$str,$m);
print_r($m["1"]);
?>

解决方案 »

  1.   

    或者
    //匹配,数据$m["1"]就是所有数字的集合
    preg_match_all("'<img src=\"(\d+)\.'",$str,$m);
    //结合
    $newstr=implode("",$m["1"]);
    echo $newstr;总之得到的各个值都在数据 $m["1"] 中。$m是个二维数组
      

  2.   

    $text = "上面那段";
    prge_match_all("/(\d)\.jpg/",$text,$regs);
    $ar = $regs[1];print_r($ar);
      

  3.   

    <?
    $str='<HTML>
    <HEAD>
    <TITLE></TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD><BODY>
    <img src="0.jpg" width=59 height=59>
    <img src="1.jpg" width=59 height=59>
    <img src="1.jpg" width=59 height=59>
    <img src="2.jpg" width=59 height=59>
    <img src="4.jpg" width=59 height=59>
    <img src="3.jpg" width=59 height=59>
    </BODY>';preg_match_all("'<img src=\"([0-9]+)\.'",$str,$m);
    print_r($m["1"]);
    ?>