$temp=explode("<td>", $testphp);
$temp=explode("</td>", $temp[1]);
echo $temp[0];

解决方案 »

  1.   

    谢谢你!举个例子,如果想提取http://www.iciba.net/dictionary/search.asp?inputword=hello里面的翻译呢?我试了几次都没成功呢?
      

  2.   

    <?php
    $handle = fopen ("http://www.iciba.net/dictionary/search.asp?inputword=hello", "r");
    while (!feof ($handle)) {
        $buffer = fgets($handle);
    echo $buffer;
    }
    fclose ($handle);
    ?>
    这样就可以了,你试试看
    我这里已经取到了
      

  3.   

    是啊,谢谢你 nethermit(网络隐士) 但我试了几次都没成功啊!我是新手,望指教一二!
    <?php
    $handle = fopen ("http://www.iciba.net/dictionary/search.asp?inputword=hello", "r");
    while (!feof ($handle)) {
        $buffer = fgets($handle,1024);

    $temp=explode("<span id=\"lbExplain\">", $buffer);
    $temp=explode("</span>", $temp[1]);
    echo $temp[0];
    #######################################################################
    #######################################################################
    //    echo $buffer;
    }fclose ($handle);?>
      

  4.   

    这就是了,恭喜恭喜,你悟道了!
    如果你的$buffer没用的话,$temp也不需要开,直接
    $buffer = fgets($handle,1024);
    $buffer = explode("<span id=\"lbExplain\">", $buffer);
    $buffer = explode("</span>", $buffer[1]);
    节约一个变量
      

  5.   

    你没有成功是因为你用了$buffer推荐你用file_get_contents函数
    程序这样写
    <?
    $buffer = file_get_contents("http://www.iciba.net/dictionary/search.asp?inputword=hello");
    $buffer = explode("<span id=\"lbExplain\">", $buffer);
    $buffer = explode("</span>", $buffer[1]);
    echo $buffer[0];
    ?>
      

  6.   

    你用的PHP版本是多少?
    file_get_contents需要4.3.0以上
      

  7.   

    搞不懂你干什么不自己分析一下页面,用这个肯定可以,关掉防火墙
    <?
    $buffer = file_get_contents("http://www.iciba.net/dictionary/search.asp?inputword=hello");
    $buffer = explode("<body>", $buffer);
    $buffer = explode("</body>", $buffer[1]);
    echo $buffer[0];
    ?>
      

  8.   

    呵呵,这就是高手与新手的差别,我分析了半天了,但不明白explode的作用,看了文档,还是似懂非懂的!谢谢你了!