本帖最后由 xiachao2008 于 2012-03-31 10:04:12 编辑

解决方案 »

  1.   

    var_export这个数组 再贴出来
      

  2.   

    给出[content]的值,并说明你要得到什么
      

  3.   

    很可能符号的问题。
    建议在存放数组元素前,加上 htmlspecialchars();
    在取元素时,htmlspecialchars_decode();
      

  4.   

    原数组是这样的
    <?php return array(0,array (
      'title' => '迅雷电视剧',
      'encoding' => 'gbk',
      'listlink' => '&lt;div class=\\&quot;operbox\\&quot;&gt;&lt;a  class=\\&quot;on\\&quot; href=\\&quot;[$ppvod]\\&quot;',
      'listpicstr' => '_src=\\&quot;[$ppvod]\\&quot;',
      'listname' => '_src=\\&quot;[$ppvod]\\&quot;',
      'replace' => 
      array (
        'listname' => '&lt;[^&gt;]+&gt;$$$',
        'vodname' => '&lt;[^&gt;]+&gt;$$$',
        'actor' => '&lt;[^&gt;]+&gt;$$$',
        'director' => '&lt;[^&gt;]+&gt;$$$',
        'content' => '&lt;[^&gt;]+&gt;$$$',
        'vodpic' => '&lt;[^&gt;]+&gt;$$$',
        'continu' => '&lt;[^&gt;]+&gt;$$$',
        'area' => '&lt;[^&gt;]+&gt;$$$',
        'playtime' => '&lt;[^&gt;]+&gt;$$$',
        'grade' => '&lt;[^&gt;]+&gt;$$$',
        'url' => '&lt;[^&gt;]+&gt;$$$',
      ),
      'name' => '&lt;strong class=\\&quot;movieDetail_tt\\&quot;&gt;[$ppvod]&lt;/strong&gt;',
      'actor' => '&lt;li&gt;[$ppvod]&lt;/a&gt;&lt;/li&gt;',
      'director' => '&lt;p&gt;&lt;strong&gt;导演:&lt;/strong&gt;[$ppvod]&lt;/p&gt;',
      'content' => '&lt;div class=\\&quot;box_con box_con_movieinfo\\&quot;&gt;[$ppvod]&lt;a target=\\&quot;_blank\\&quot;',
      'pic' => '',
      'continu' => '',
      'area' => '&lt;li&gt;标签:[$ppvod]&lt;/li&gt;',
      'playtime' => '&lt;p&gt;&lt;strong&gt;片长:&lt;/strong&gt;&lt;span&gt;[$ppvod]分钟&lt;/span&gt;&lt;/p&gt;',
      'grade' => '',
      'language' => '&lt;ul id=\\&quot;ul_subLabel\\&quot; class=\\&quot;diversity_white_ul \\&quot;&gt;[$ppvod]&lt;/ul&gt;',
      'year' => '&lt;p&gt;&lt;strong&gt;上映:&lt;/strong&gt;[$ppvod]&lt;/p&gt;',
      'urlname' => 'title=\\&quot;[$ppvod]\\&quot;',
      'urllink' => '&lt;a href=\\&quot;[$ppvod]\\&quot; title=',
      'url' => '',
      'submit' => '确定',
    ));
      

  5.   

    加了以后能调用啊: $a =" <div class=\"box_con box_con_movieinfo\">([\s\S]*?)<a target=\"_blank\"";
     $b = htmlspecialchars($a);
     $c = array(123,$b,array($b));
     print_r($c);
     /* -------- 输出 --------*/
    Array ( [0] => 123 
    [1] =>  <div class="box_con box_con_movieinfo">([\s\S]*?)<a target="_blank" 
    [2] => Array ( [0] =>  <div class="box_con box_con_movieinfo">([\s\S]*?)<a target="_blank" ) ) 
      

  6.   

    大哥,你这种在浏览器页面下看是正确的,但是在源码下看还是html原生态的嘛Array
    (
        [0] => 123
        [1] =>  &lt;div class=&quot;box_con box_con_movieinfo&quot;&gt;([\s\S]*?)&lt;a target=&quot;_blank&quot;
        [2] => Array
            (
                [0] =>  &lt;div class=&quot;box_con box_con_movieinfo&quot;&gt;([\s\S]*?)&lt;a target=&quot;_blank&quot;
            ))
    我的数组用途是正责匹配网页内容的。
      

  7.   


     $a =" <div class=\"box_con box_con_movieinfo\">([\s\S]*?)<a target=\"_blank\"";
     $b = htmlspecialchars($a);
     $c = array(123,$b,array($b));$d = htmlspecialchars_decode($c[2][0]);
    echo "d-->>".$d."<br>";
    /*输出,浏览器界面已将标签解析*/
    d-->> 
    ([\s\S]*?)
    /*源码*/
    d-->>[b] <div class="box_con box_con_movieinfo">([\s\S]*?)<a target="_blank"<br>好吧,你要用那个值?
      

  8.   


    $replace = xunleiReplace();
    $replace = htmlDecode($replace);
    echo "<pre>";print_r($replace['content']);exit(); function getrole($str){//规则替换
    //$str = str_replace(array("\n","\r"),array("<nr/>","<rr/>"),strtolower($str));
    $arr1 = array('?','"','(',')','[',']','.','/','*','||',);
    $arr2 = array('\?','\"','\(','\)','\[','\]','\.','\/','.*?','(.*?)',);
    //$str = str_replace(array("\n","\r"),array("<nr/>","<rr/>"),strtolower($str));
    return str_replace('\[$ppvod\]','([\s\S]*?)',str_replace($arr1,$arr2,$str));
    }
       function htmlDecode($replace){
       foreach ( $replace as $key => $val){
       if(is_array($val)){
         foreach ( $val as $keys => $values){
         $replace[$key][$keys] = htmlspecialchars_decode(getrole($values));    
         }   
       }else {
         $replace[$key] = htmlspecialchars_decode(getrole($val));    
       }  
       }
         return  $replace;
       }
          function xunleiReplace(){
       return array(
      'title' => '迅雷电视剧',
      'encoding' => 'gbk',
      'listlink' => '&lt;div class=\\&quot;operbox\\&quot;&gt;&lt;a  class=\\&quot;on\\&quot; href=\\&quot;[$ppvod]\\&quot;',
      'listpicstr' => '_src=\\&quot;[$ppvod]\\&quot;',
      'listname' => '_src=\\&quot;[$ppvod]\\&quot;',
      'replace' => 
      array (
        'listname' => '&lt;[^&gt;]+&gt;$$$',
        'vodname' => '&lt;[^&gt;]+&gt;$$$',
        'actor' => '&lt;[^&gt;]+&gt;$$$',
        'director' => '&lt;[^&gt;]+&gt;$$$',
        'content' => '&lt;[^&gt;]+&gt;$$$',
        'vodpic' => '&lt;[^&gt;]+&gt;$$$',
        'continu' => '&lt;[^&gt;]+&gt;$$$',
        'area' => '&lt;[^&gt;]+&gt;$$$',
        'playtime' => '&lt;[^&gt;]+&gt;$$$',
        'grade' => '&lt;[^&gt;]+&gt;$$$',
        'url' => '&lt;[^&gt;]+&gt;$$$',
      ),
      'name' => '&lt;strong class=\\&quot;movieDetail_tt\\&quot;&gt;[$ppvod]&lt;/strong&gt;',
      'actor' => '&lt;li&gt;[$ppvod]&lt;/a&gt;&lt;/li&gt;',
      'director' => '&lt;p&gt;&lt;strong&gt;导演:&lt;/strong&gt;[$ppvod]&lt;/p&gt;',
      'content' => '&lt;div class=\\&quot;box_con box_con_movieinfo\\&quot;&gt;[$ppvod]&lt;a target=\\&quot;_blank\\&quot;',
      'pic' => '',
      'continu' => '',
      'area' => '&lt;li&gt;标签:[$ppvod]&lt;/li&gt;',
      'playtime' => '&lt;p&gt;&lt;strong&gt;片长:&lt;/strong&gt;&lt;span&gt;[$ppvod]分钟&lt;/span&gt;&lt;/p&gt;',
      'grade' => '',
      'language' => '&lt;ul id=\\&quot;ul_subLabel\\&quot; class=\\&quot;diversity_white_ul \\&quot;&gt;[$ppvod]&lt;/ul&gt;',
      'year' => '&lt;p&gt;&lt;strong&gt;上映:&lt;/strong&gt;[$ppvod]&lt;/p&gt;',
      'urlname' => 'title=\\&quot;[$ppvod]\\&quot;',
      'urllink' => '&lt;a href=\\&quot;[$ppvod]\\&quot; title=',
      'url' => '',
      'submit' => '确定',
    );     }
    你的方法我试了,但是我在数组里操作的时候,还是不行啊,
    还是取不值,还是少了一部份??可以帮我看看吗??
    看来问题是出在数组上。但是我以经不知道从何下手找这个数组错误了。
      

  9.   

    用你的代码打印出的结果:$replace = xunleiReplace();
    $replace = htmlDecode($replace);
    echo "<pre>";print_r($replace['content']);exit();
    /*输出*/
    ([\s\S]*?)<a target=\"_blank\"
    /*源码*/
    <pre><div class=\"box_con box_con_movieinfo\">([\s\S]*?)<a target=\"_blank\"
      

  10.   

    是不是从
    <div class=\"box_con box_con_movieinfo\">到<a target=\"_blank\"
    之间出现了<a target=\"_blank\"。提早截断了额。加个贪婪标识试试
      

  11.   


    $replace = xunleiReplace();
    /* 1 */
    print_r($replace['content']);echo"<br>";
    //输出
    //<div class=\"box_con box_con_movieinfo\">[$ppvod]<a target=\"_blank\"
    //源码
    //&lt;div class=\&quot;box_con box_con_movieinfo\&quot;&gt;[$ppvod]&lt;a target=\&quot;_blank\&quot;$replace = htmlDecode($replace);
    /* 2 */
    print_r($replace['content']);exit();
    //输出
    //([\s\S]*?)<a target=\"_blank\"
    //源码
    //<div class=\"box_con box_con_movieinfo\">([\s\S]*?)<a target=\"_blank\"这两个里面你要用那个值?还是一个都没有?
      

  12.   

    同样的源码,我们输出的值不样给。
    我输出的是
    <div class=\"box_con box_con_movieinfo\">([\s\S]*?)