note 68947 deleted from function.highlight-string by betz

From: Date: Wed, 16 Aug 2006 22:02:12 +0000
Subject: note 68947 deleted from function.highlight-string by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115988@lists.php.net to get a copy of this message
Note Submitter: Wdeah Reason: non-english ---- <? // Un ejemplo de como hacer que se vea el numero de lineas // y que no moleste para nada, a la hora de seleccionar el codigo. // agregamos ceros, para que todas las lineas numericas tengan la misma longitud. // 001 // 010 // 100 function agregar0 ($cuantos) { for ($i=0; $i < $cuantos; $i++) { $dev = $dev.'0'; } return $dev; } // parseamos el codigo que nos devuelve la funcion highlight_string function HLS_xhtml ($str) { $str = highlight_string(stripslashes($str), true); $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str); $str = preg_replace('#color="(.*?)"#', 'style="color: \\1;"', $str); $str = str_replace('<code>', '<code style="white-space: nowrap;">', $str); // obtenemos el numero de lineas $lineas = explode("<br />", $str); ?> <div style="background-color: #0099CC; width: 542px; border: 1px solid #B0B0B0;"> <div style="float: left; color: #FFF; padding: 0 0 0 4px; "> <code style="white-space: nowrap;"> <? // agregamos las lineas en el documento... for ($i=1; $i <= count($lineas); $i++) { $a = strlen(count($lineas)); print agregar0($a - strlen($i)).$i.'<br />'; } ?> </code> </div> <div style="float: right; width: 495px; background-color: #F8F8F8; overflow: auto; overflow-y: hidden; padding: 0 0 0 4px;" id="codigo"><? print $str; ?><br />&nbsp;</div> <div style="clear: both;"><!-- --></div> </div> <? } // ejemplo de uso: $file = file_get_contents(__FILE__); HLS_xhtml($file); #WDEAH ?>

« previous php.notes (#115988) next »