你的结果是
array(3) { [0]=> string(9) "[hehe] string(6) "[hehe]" [2]=> string(3) " <m" } 
不知道你想要的结果是什么样的???

解决方案 »

  1.   

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    期待取出这段
      

  2.   

    "/<meta.*?>/"
    用这个试试
      

  3.   

    preg_match("/\[hehe\]([^\[hehe\]].*)\[\/hehe\]/i",'[hehe] <meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]', $test); 
    var_dump($test);
      

  4.   

    "/<meta[^\>]*>/i"
    试试 
      

  5.   

    preg_match("/\[hehe\]+([^>]+)/ie",'[hehe]<meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]', $test); 
    print_r($test);
      

  6.   

    <?php
    preg_match("/\[hehe\](.*)\[\/hehe\]/i",'[hehe] <meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]', $test);
    var_dump($test);
    ?>
      

  7.   

    preg_match("/(\[hehe\])(.*)(\[\/hehe\])/i",'[hehe]  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]', $test); 
    var_dump($test); 
      

  8.   

    [hehe]<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]我的意思是里面不一定只有一条的
      

  9.   

    <?php 
    preg_match("/(\[hehe\])(.*)(\[\/hehe\])/i",'[hehe]  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]', $test); 
    var_dump($test); 
    ?> 
    结果是: [2]不是你要的吗?
    array(4) {
      [0]=>
      string(287) "[hehe]  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]"
      [1]=>
      string(6) "[hehe]"
      [2]=>
      string(274) "  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="Content-Type" content="text/html; charset=gb2312">"
      [3]=>
      string(7) "[/hehe]"
    }
      

  10.   

    array(4) { [0]=> string(291) "[hehe] [/hehe]" [1]=> string(6) "[hehe]" [2]=> string(278) " " [3]=> string(7) "[/hehe]" } - -为什么我是这样的。迷茫一下下
      

  11.   

    preg_match("/(\[hehe\])(.*)(\[\/hehe\])/i",'[hehe]   <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">[/hehe]', $test);  
    var_dump($test); 
    array(4) { [0]=> string(291) "[hehe] [/hehe]" [1]=> string(6) "[hehe]" [2]=> string(278) " " [3]=> string(7) "[/hehe]" } 
      

  12.   

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    如果我要取出 gb2312或UTF-8要怎么样写呢?