Today, I’d like to share a pretty useful function, which turn a html source into a full text document by removing all html tags and other unneeded code.
function html2txt($document){
$search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<[?]php[^>].*?[?]>@si', //scripts php
'@<[?][^>].*?[?]>@si', //scripts php
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
);$text = preg_replace($search, '', $document);
return $text;
}

Put the result of phpinfo() in a file
No comments yet
The phpinfo() function is very useful to get all kinds of information about the server you’re working on. But what about saving the result of the function in a file instead of displaying it on screen?
The following snippet will do that.
ob_start(); phpinfo(); file_put_contents('filename.txt', ob_get_clean());Read More »