Mailinglisten-Archive |
Hi, > Weiss jemand einen Link, Rat, Hinweis? ja, diese Funktion habe ich für meine Homepage geschrieben - aber leider nicht kommentiert... // formatiert fertigen HTML-Code function format($page) { $page = ereg_replace("\n", " ", $page); $page = ereg_replace(" ", " ", $page); $page = ereg_replace("<", "\n<", $page); $page = ereg_replace("}; ", "};\n", $page); $page = ereg_replace(">", ">\n", $page); $page = ereg_replace("\n ", "\n", $page); $page = ereg_replace("\n\n", "\n", $page); $lines = explode("\n", $page); $page = ""; $spaces = " "; $offset = 0; $tab = 2; for ($x=0; $x<sizeof($lines); $x++) { $noffset = 0; $li = strtolower($lines[$x]); $npre = $pre; if ((substr($li,0,5) == "<pre>") || (substr($li,0,9) == "<textarea")) { $npre = $pre = TRUE; } if ((substr($li,0,6) == "</pre>") || (substr($li,0,11) == "</textarea>")) { $npre = FALSE; } if (!$pre) { if ((substr($li,0,1) == "<") && (substr($li,0,4) != "<br>") && (substr($li,0,4) != "<hr>") && (substr($li,1,1) != "!") && (substr($li,1,4) != "img ") && (substr($li,1,5) != "link ") && (substr($li,1,5) != "meta ") && (substr($li,1,6) != "input ") && (substr($li,1,5) != "/pre>") ) { if (substr($li,1,1) == "/") { if ($offset >= $tab) { $offset -= $tab; } } else { $noffset = $tab; } } $page .= substr($spaces,strlen($spaces)-$offset); } if ($pre) { if ($li != "<br>") { $page .= $lines[$x]."\n"; } } else { $page .= $lines[$x]."\n"; } $offset += $noffset; $pre = $npre; } return($page); } Gruß, Reinhold -- Reinhold Jordan WWW: http://reinhold.bachrain.de Mail: reinhold_(at)_bachrain.de "Do you pine for the nice days of minix-1.1, when men were men and wrote their own device drivers?" Linus
php::bar PHP Wiki - Listenarchive