Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
Ами да ама аз искам да е специално за кодове като тоя на снимката острани със номерца иначе другите (b,i,u) мисля , че мога да ги направяsvilkaa каза:http://www.phpit.net/article/create-bbcode-php/1/
http://www.phpit.net/article/create-bbcode-php/2/
Мерси много adrian но нещо не мога да направя този скрипт:adrian каза:Виж тази тема
Има дадени много варианти за правене на точно това, което искаш. Мисля, че на jooorooo както винаги е най-добрия
Разгледай цялата тема :?:
function get_sourcecode_string($str, $return = false, $counting = true, $first_line_num = '1', $font_color = '#666'){
$str = highlight_string($str, TRUE);
$replace = array(
'<font' => '<span',
'color="' => 'style="color: ',
'</font>' => '</span>',
'<code>' => '',
'</code>' => '',
'<span style="color: #FF8000">' =>
'<span style="color: '.$font_color.'">'
);
foreach ($replace as $html => $xhtml){
$str = str_replace($html, $xhtml, $str);
}
// delete the first <span style="color:#000000;"> and the corresponding </span>
$str = substr($str, 30, -9);
$arr_html = explode('<br />', $str);
$total_lines = count($arr_html);
$out = '';
$line_counter = 0;
$last_line_num = $first_line_num + $total_lines;
foreach ($arr_html as $line){
$line = str_replace(chr(13), '', $line);
$current_line = $first_line_num + $line_counter;
if ($counting){
$out .= '<span style="color:'.$font_color.'">'
. str_repeat(' ', strlen($last_line_num) - strlen($current_line))
. $current_line
. ': </span>';
}
$out .= $line
. '<br />'."\n";
$line_counter++;
}
$out = '<code>'."\n".$out."</code>"."\n";
if ($return){return $out;}
else {echo $out;}
}
нататъка си ти ...<?php
$page = '<code>html code</code>';
$page = preg_replace( '/<code>(.*)<\/code>/', '<div style="padding: 20px; width: 100%; background: #eee; border: 1px solid #D5D5D5;">$1</div>', $page );
echo '<strong>Code</strong>';
echo $page;
?>
<?php
$page = 'texttexttexttext<code>html code html code html code</code>texttexttexttexttext';
$page = preg_replace( '/<code>(.*)<\/code>/', '<div style="padding: 20px; width: 100%; background: #eee; border: 1px solid #D5D5D5;">$1</div>', $page );
echo $page;
?>