$url="http://www.weather.com.cn/weather/101010100.shtml";
$html=file_get_contents($url);
$result=preg_match("/[<][!]([0-9a-zA-Z\/\"\.\S ])+/",$html,$match);
var_dump($match);输出:array(2) { [0]=> string(97) "" [1]=> string(1) ">" }  // 为什么显示97个字符却没有任何字符输出呢?

解决方案 »

  1.   

    是因为输出结果里面有html标签!
    所以 你通过右键  查看源代码 就能看到输出字符了!
      

  2.   

                  <a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
                    北风
                  </a>
                </td>            <td>
                  <a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
                    3-4级
                  </a>
                </td>
              </tr>
              </table>  //我想用正则截取到这边,不能单纯的用</table>结束,因为后面还有
    很多<table>,必须要用</td>和</tr>和</table>结合起来结尾,请问该怎么写

                .
                .
                .这是我自己写的:"/<div class=\"weatherYubaoBox\">(.*)<\/td>([\S])*<\/tr>([\S])*<\/table>/s"
    可是用不了!!(红色部分代表结尾部分
        
      

  3.   

    你把你要抓取什么东西说清楚!我刚看了下weatherYubaoBox有两个!~~你得说清楚你要什么数据 !
      

  4.   

    "/<div class=\"weatherYubaoBox\">(.*?)<\/td>\s*<\/tr>\s*<\/table>/s"