class="EventCanSelect" title="正品 mm木村井泓 2011年流行斜挎包/单肩包 330016">请问怎么用preg_match_all语句匹配出 title引号里的内容
谢谢帮忙。

解决方案 »

  1.   

    preg_match('/title="(.*?)"/',$str,$arr);
    echo $arr[1];
      

  2.   

    你看看这样行不行$str='class="EventCanSelect" title="正品 mm木村井泓 2011年流行斜挎包/单肩包 330016">';
    preg_math_all('\title=".*?"\',$str,$match);
     你看看行不行 没有测式。
      

  3.   

    2楼的可以匹配到,请问如何能循环匹配呢,一个页面上有很多相同的代码,匹配所有符合条件的到一个数组class="EventCanSelect" title="xxx">xxx代表 一个变量
      

  4.   

    if(preg_match('/title="([^"]*)"/i',$str,$matchs)){
      var_dump($matchs);
    }
      

  5.   

    直接用类库啊,simple html dom 自己google一下,很简单的语法,
    $dom = new simple_html_dom();
    $dom->load($html);//页面html
    $title = $dom->find("p[class=EventCanSelect]", 0)->title;
    echo $title;
    不过要注意字符编码。