PHP Classes

File: example2.php

Recommend this page to a friend!
  Classes of Martin Sadera   Power HTML Cleaner   example2.php   Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: Example script 2
Class: Power HTML Cleaner
Process HTML documents to remove unwanted tags
Author: By
Last change: Changed function array_walk_recursive() which is supported only in PHP5 by function array_walk() supported from PHP version 3
Date: 17 years ago
Size: 873 bytes
 

Contents

Class file image Download
<?
function ArrCombine($item, $key) {
  global
$html;
 
$html.=$item;
  }
function
getmicrotime() {
  list(
$usec, $sec) = explode(" ",microtime());
  return ((float)
$usec + (float)$sec);
  }


$start_time=getmicrotime();

## GET CONTENT FROM FILE ##
$file = (file("test.htm"));
array_walk($file, 'ArrCombine');

## MAKE CLEANER INSTANCE
require ("cleanhtml.class.php");
$xhtml=new HtmlCleaner($html);

## SET ALLOWED TAGS IN CODE
$xhtml->allowedTags(array("<table>","<th>","<td>","<tr>","<tbody>","<thead>"));

echo
'<fieldset><legend>Before cleaning:</legend><textarea rows="20" cols="80">'.$html.'</textarea></fieldset>';
echo
'<fieldset><legend>After cleaning:</legend><textarea rows="20" cols="80">'.$xhtml->GetCleanedHtml().'</textarea></fieldset>';

$end_time=getmicrotime();

echo
"<hr />Clean time ".($end_time-$start_time)." s";

?>