ahora si .. anda medio lenta mi maquina :(
Código PHP:
Ver original<?php
class tabulador{
private $code;
private $_tbs;
private $tbs;
private $cache;
public function __construct($code){
$this->code = $code;
}
public function tabular($tabkey = "\t"){
$this->code = preg_replace('@>([\n\r\s]+)<@', '><', $this->code); $this->code = preg_replace('@([\n\r\t]{1,})@', '', $this->code); $this->code = preg_replace('@(<!doctype([^>]*)>)@i', "$1\n", $this->code); for($t=0;$this->cache!=$this->code;++$t){
$this->cache=$this->code;
$this->code = preg_replace('@<(\w+)([^>]*)>(.*?)</\1>@', "<$1$2>\n".$this->tbs."$3\n".$this->_tbs
."</$1>\n".$this->_tbs
, $this->code); }
//$this->code = preg_replace("@($tabkey*)<(\w+)([^>]*)/>@", "\n<$2$3/>\n", $this->code);
$this->code = preg_replace("@[\n\r]$tabkey*[\n\r]@", "\n", $this->code); return trim($this->code); }
}
//$texto = "<span><div><input /><input /><input /><input /></div></span>";
$tab = new tabulador($texto);
echo $tab->tabular(" ");
?>
saludos