Ver Mensaje Individual
  #3 (permalink)  
Antiguo 06/05/2010, 10:21
Hidek1
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 15 años, 3 meses
Puntos: 334
Respuesta: Indentado en PHP y HTML... grrr

ahora si .. anda medio lenta mi maquina :(

Código PHP:
Ver original
  1. <?php
  2. class tabulador{
  3.     private $code;
  4.     private $_tbs;
  5.     private $tbs;
  6.     private $cache;
  7.     public function __construct($code){
  8.         $this->code = $code;
  9.     }
  10.     public function tabular($tabkey = "\t"){
  11.         $this->code = preg_replace('@>([\n\r\s]+)<@', '><', $this->code);
  12.         $this->code = preg_replace('@([\n\r\t]{1,})@', '', $this->code);
  13.         $this->code = preg_replace('@(<!doctype([^>]*)>)@i', "$1\n", $this->code);
  14.         for($t=0;$this->cache!=$this->code;++$t){
  15.             $this->cache=$this->code;
  16.             $this->_tbs = str_repeat($tabkey, $t);
  17.             $this->tbs = str_repeat($tabkey, $t+1);
  18.             $this->code = preg_replace('@<(\w+)([^>]*)>(.*?)</\1>@', "<$1$2>\n".$this->tbs."$3\n".$this->_tbs."</$1>\n".$this->_tbs, $this->code);
  19.         }
  20.         //$this->code = preg_replace("@($tabkey*)<(\w+)([^>]*)/>@", "\n<$2$3/>\n", $this->code);
  21.         $this->code = preg_replace("@[\n\r]$tabkey*[\n\r]@", "\n", $this->code);
  22.         return trim($this->code);
  23.     }
  24. }
  25. //$texto = "<span><div><input /><input /><input /><input /></div></span>";
  26. $texto = file_get_contents("http://www.google.cl");
  27. $tab = new tabulador($texto);
  28. echo $tab->tabular("    ");
  29. ?>

saludos
__________________
More about me...
~ @rhyudek1
~ Github