Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Sadera  >  Power HTML Cleaner  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example script 1
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: 2006-04-20 03:42
Size: 692 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>","<p>"));

## SAVE RESULT TO FILE
$xhtml->saveToFile("cleaned-test.htm");

$end_time=getmicrotime();

echo 
"Clean time ".($end_time-$start_time)." s";

?>