为什么在本地搭建的DedeAMPZ环境中都没有问题,放到linux服务器上面中有空格和换行的就截取不到了

解决方案 »

  1.   

    在本地搭建的DedeAMPZ环境中测试有空格和换行都能截取到,但是放到linux服务器中有空格和换行的就截取不到了
    function array($html,$star,$end){
    $words='';
    $pattern = '/'.$star.'(.*?)'.$end.'/s';
    if(!preg_match_all($pattern, $html, $match)) {                
    }else{
    $words= $match[0];
    }
    return $words;
    }
    $list = array($content,'<a ','<br \/>
    <a');
      

  2.   

    Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting identifier 
    array 是保留字,不能挪作他用!
    你的代码根本不能运行
      

  3.   

    代码我忘记少写了啊,不好意思
    function ge_array($html,$star,$end){
    $words='';
    $pattern = '/'.$star.'(.*?)'.$end.'/s';
    if(!preg_match_all($pattern, $html, $match)) {                
    }else{
    $words= $match[0];
    }
    return $words;
    }
    $list = ge_array($content,'<a ','<br \/>
    <a'); 
      

  4.   

    你是说 $star 或 $end 中出现换行时就不正常了,是这个意思吗?
    这是很正常的,在不同的操作系统中换行的表示是不同的:
    windows \r\n 一个回车符加一个新行符
    Linux \n 一个新行符
    Mac \r 一个回车符所以在正则表达式中应用:[\r\n]+ 表示
    一般的 \s+ 就可以了
      

  5.   

    function ge_array($html,$star,$end){
    $words='';
    $pattern = '/'.$star.'(.*?)'.$end.'/s';
    if(!preg_match_all($pattern, $html, $match)) {                
    }else{
    $words= $match[0];
    }
    return $words;
    }
    Linux系统中该怎么修改啊版主
      

  6.   

    function ge_array($html,$star,$end){
    $words='';
    $pattern = '/'.$star.'(.*?)'.$end.'/s';
    if(!preg_match_all($pattern, $html, $match)) {                
    }else{
    $words= $match[0];
    }
    return $words;
    }
    Linux系统中该怎么修改啊版主