ja nur bei deiner funktion ist das problem wenn mann diesen beitrag bearbeitet dann hat man lauter ///// da drinne
--======================================--
--== Beitrag erstellt: 14:03 um 13:59 ==--
--== geantwortet auf Beitrag vom ==--
--== automatische Beitragszusammenführung ==--
--======================================--
asus schrieb nach 4 Minuten und 14 Sekunden:
also wenn ich es poste ist es ja so
PHP-Code:
<?php
function highlight_phpx($str,$typ = 'code', $echo = false, $counting = true, $first_line_num = '1')
{
//$str = str_replace(array('<', '>','&', '"'), array('<', '>', '&', '"'), $str);
$str = htmlspecialchars_decode($str);
if(strtolower($typ) == 'php')
{
if ( strpos(substr ( $str, 0,6),'<?php') === false || strpos(substr ( $str, 0,3),'<?') === false)
{
$str = "<?php \r\n".$str;
}
if ( strpos(substr ( $str, -3),'?'.'>') === false)
{
$str = $str." \r\n?".">";
}
}
ob_start();
highlight_string($str);
$str=ob_get_contents();
ob_end_clean();
$arr_str = explode('<br />', $str);
$total_lines = count($arr_str);
$code = '';
$lines = '';
$height = '';
$line_counter = 0;
$last_line_num = $first_line_num + $total_lines;
if ($total_lines > 16)
{
$height = $total_lines*12-1;
if ($height > 500)
$height = 500;
$height = ' height: '.$height.'px;';
}
foreach ($arr_str as $line)
{
$current_line = $first_line_num + $line_counter;
if ($counting)
$lines .= $current_line. ':'."\r\n";
$code .= $line;
$line_counter++;
}
$code = substr ( $code, 36, -9);
// $code = substr ( $code, 0, strlen($code)-8);
$r = '<div style="width: 640px; border-left: 1px solid #000000;border-top: 1px solid #000000;border-right: 1px solid #000000;background: #AFAFAF;color:white;">'.strtoupper($typ).(strtoupper($typ) != 'CODE' ? ' CODE' : '').':</div><div style="overflow: auto;width: 640px; border: 1px solid #000000;'.$height.'"><table style="width: 100%;'.$height.'" cellspacing="0" valign="top" align="top"><tr><td valign="top" style="background: #AFAFAF;border-right: 1px solid #000000;color:white;" width=25 align="top"><code><nobr>'.$lines.'</nobr></code></td><td style="background: #EFEFEF;color:black;" valign="top" align="top"><code><nobr>'.$code.'</nobr></code></td></tr></table></div>';
if ($echo === false){return $r;}
else {echo $r;}
}
?>
wenn ich mein beitrag bearbeite dann hab ich es so
PHP-Code:
<?php
function highlight_phpx($str,$typ = 'code\', $echo = false, $counting = true, $first_line_num = \'1\')
{
//$str = str_replace(array(\'<\', \'>\',\'&\', \'"\'), array(\'<\', \'>\', \'&\', \'\"\'), $str);
$str = htmlspecialchars_decode($str);
if(strtolower($typ) == \'php\')
{
if ( strpos(substr ( $str, 0,6),\'<?php\') === false || strpos(substr ( $str, 0,3),\'<?\') === false)
{
$str = \"<?php \\r\\n\".$str;
}
if ( strpos(substr ( $str, -3),\'?\'.\'>\') === false)
{
$str = $str.\" \\r\\n?\".\">\";
}
}
ob_start();
highlight_string($str);
$str=ob_get_contents();
ob_end_clean();
$arr_str = explode(\'<br />\', $str);
$total_lines = count($arr_str);
$code = \'\';
$lines = \'\';
$height = \'\';
$line_counter = 0;
$last_line_num = $first_line_num + $total_lines;
if ($total_lines > 16)
{
$height = $total_lines*12-1;
if ($height > 500)
$height = 500;
$height = \' height: \'.$height.\'px;\';
}
foreach ($arr_str as $line)
{
$current_line = $first_line_num + $line_counter;
if ($counting)
$lines .= $current_line. \':\'.\"\\r\\n\";
$code .= $line;
$line_counter++;
}
$code = substr ( $code, 36, -9);
// $code = substr ( $code, 0, strlen($code)-8);
$r = \'<div style=\"width: 640px; border-left: 1px solid #000000;border-top: 1px solid #000000;border-right: 1px solid #000000;background: #AFAFAF;color:white;\">\'.strtoupper($typ).(strtoupper($typ) != \'CODE\' ? \' CODE\' : \'\').\':</div><div style=\"overflow: auto;width: 640px; border: 1px solid #000000;\'.$height.\'\"><table style=\"width: 100%;\'.$height.\'\" cellspacing=\"0\" valign=\"top\" align=\"top\"><tr><td valign=\"top\" style=\"background: #AFAFAF;border-right: 1px solid #000000;color:white;\" width=25 align=\"top\"><code><nobr>\'.$lines.\'</nobr></code></td><td style=\"background: #EFEFEF;color:black;\" valign=\"top\" align=\"top\"><code><nobr>\'.$code.\'</nobr></code></td></tr></table></div>\';
if ($echo === false){return $r;}
else {echo $r;}
}
?>