eccoti qua la funzione, baby

codice:
   1.  <?php
   2. define("NL", "\r\n");
   3. define("TAB", "\t");
   4. $output = array();
   5. if ($_POST) {
   6. echo '<h3>The Result</h3>'.NL;
   7. $html_by_line = split("\n", $_POST["html"]);
   8. if (!isset($_POST["make_list"])) {
   9. $start = "";
  10. $output[] = '
  1. '; 11. foreach ($html_by_line as $key => $line) { 12. $class = ($key % 2) ? ' odd' : ''; 13. if (trim($line) == "") { 14. $output[] = TAB.'<li class="'.$class.'">&#160;'; 15. } 16. else if (preg_match("/^(\s)+/", $line, $regs)) { 17. $output[] = TAB.'<li class="tab'.strlen($regs[0]).$class.'">'.highlight_string(trim($line), true).''; 18. } 19. else { 20. $output[] = TAB.'<li class="'.trim($class).'">'.highlight_string(trim($line), true).'</code>'; 21. } 22. } 23. $output[] = '
'.NL; 24. $echo = join(NL, $output); 25. 26. echo stripslashes($echo); 27. echo '<pre>'.stripslashes(htmlentities($echo)).'</pre>'; 28. } 29. else { 30. foreach ($html_by_line as $line) { 31. if (preg_match("/^(\s)+/", $line, $regs)) 32. $start = str_pad($start, strlen($regs[0]), ''); 33. if (trim($line) == "") 34. $output[] = NL; 35. else 36. $output[] = $start . htmlentities(trim($line)).NL; 37. } 38. $echo = join(NL, $output); 39. echo '<pre><code>'.$echo.'</code></pre>'.NL; 40. } 41. } 42. else if ($_GET) {echo "you need to post the code";} 43. ?>