w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
PHP: How to use tidy to just minify a string and no repair it

Below example may help you:

function html2txt($document){
$search = array('@<script[^>]*?>.*?</script>@si',  // Strip
out javascript
               '@<[/!]*?[^<>]*?>@si',            // Strip out
HTML tags
               '@<style[^>]*?>.*?</style>@siU',    // Strip
style tags properly

]*>@'         // Strip multi-line comments including CDATA
$text = preg_replace($search, '', $document);
return $text;

You can get more info on http://php.net/manual/en/function.strip-tags.php

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.