如 <title>我是中国人</title>
我要取出"我是中国人"这几个字。而不要<title>怎么做呢?

解决方案 »

  1.   

    今天刚学到的,分享给你吧。$txt='<title>我是中国人</title>'
    $txt=strip_tags($txt);
    echo $txt;
      

  2.   


    $txt='<title>我是中国人</title>';
    $txt=strip_tags($txt);
    echo $txt;
      

  3.   

    $str = '<title>我是中国人</title>';
    preg_match('/<title>(.+)<\/title>/iU',$str,$match);
    print_r($match[1]);
      

  4.   


    $txt = "测试 <title>我是中国人</title>";
    preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", $txt, $out);
    printf("<b>提取结果:</b><br />\n %s", implode(", ", $out[1])); 
      

  5.   

    preg_match('/<title>([\d\D]*)<\/title>/i', $string, $matches);var_dump($matches);