GD
ImageCopyResized: 复制新图并调整大小。

解决方案 »

  1.   

    可能需要这样
    先判断是否有welcome
    1、preg_match("/\bwelcome/",$rr);
    在有的前提下,再判断是否有welcome to csdn
    2、preg_match("/\bwelcome +\bto +\bcsdn/",$rr);由于匹配串和待匹配串应该是不确定的,不能太具体化了。
    如需知道两者并存,可以从原串中删去2匹配的部分后用再用1检查单用正则表达式不能完成语法分析工作
      

  2.   

    fuction CheckStr(s)
    {
    var str = s;
    var regStr1 =  /welcome to csdn/;
    var regStr2 = /welcome/;var rst1 = str.search(regStr1);
    var r= str.replace(regStr1," ");
    var rst2 = r.search(regStr2); if(-1 == rst1 && -1 == rst2) return 1;
    if(-1 != rst1 && -1 == rst2) return 2;
    if(-1 == rst1 && -1 != rst2) return 3;
    if(-1 != rst1 && -1 != rst2) return 4;}
      

  3.   

    sorry, 上面的例子是用javascript 写的,php中function ($s){
    $str = $s;
    $cnt1 = substr_count($str,"welcome");
    $cnt2 = substr_count($str,"welcome to csdn");
    if(0==$cnt1) return 0; //either 
    if($cnt1>$cnt2 && $cnt2==0 ) return 1; // just has welcome 
    if($cnt1==$cnt2 && $cnt2>0 ) return 2; // just has welcome to csdn
    if($cnt1>$cnt2 && $cnt2>0) return3; //both
    }
      

  4.   

    function ($s){
    $str = $s;
    $cnt1 = substr_count($str,"welcome");
    $cnt2 = substr_count($str,"welcome to csdn");
    if(0==$cnt1) return 0; //either 
    if($cnt1>$cnt2 && $cnt2==0 ) return 1; // just has welcome 
    if($cnt1==$cnt2 && $cnt2>0 ) return 2; // just has welcome to csdn
    if($cnt1>$cnt2 && $cnt2>0) return3; //both
    }