清除HTML标记

/**

  • 清除HTML标记

  • @param string $str

  • @return string
    */
    function dr_clearhtml($str) {

    $str = str_replace(
    array(’ ‘, ‘&’, ‘"’, ‘’’, ‘“’, ‘”’, ‘—’, ‘<’, ‘>’, ‘·’, ‘…’), array(’ ‘, ‘&’, ‘"’, "’", ‘“’, ‘”’, ‘—’, ‘<’, ‘>’, ‘·’, ‘…’), $str
    );

    $str = preg_replace("/<[a-z]+(.*)>/iU", “”, $str);
    $str = preg_replace("//iU", “”, $str);
    $str = preg_replace("/{.+}/U", “”, $str);
    $str = str_replace(array(chr(13), chr(10), ’ '), ‘’, $str);
    s t r = s t r i p t a g s ( str = strip_tags( str=striptags(str);

    return trim($str);
    }

你可能感兴趣的:(php)