例如 file_get_contents 的内容存到一个字符串里,居然有我不想要的 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 这个HTML代码!如果在获取页面时  去除这个HTML代码啊!

解决方案 »

  1.   

    file_get_contents获取的就是完整的代码,你不可能指定不要那个段
    不过你可以获取完成后,再删除掉这一段
    用str_replace把它替换为""就行了
      

  2.   

    $file = file_get_contents("http://163.com");
    echo preg_replace("/<(.*)\/?>/isU","",$file);
      

  3.   

    如果不要所有html标记:
    preg_replace("/\<(\s*[^\>]+\s*)([\/]?)>/ies","",$str);
    仅仅不要meta:
    preg_replace("/\<meta(\s*[^\>]+\s*)([\/]?)>/ies","",$str);获取网页内容最好不要用file_get_contents,他经常出问题。
    最好用fsocket或curl