Jump to content
php.lv forumi



Recommended Posts

Sveiki, esmu man ir problēma ar bbcode.

Itkā viss iet, bet, protams, līdz tam brīdim, kad bbkods ir pa 2 rindām, piemēram:

[b]pirmā rinda
otrā rinda[/b]


Varbūt kāds var palīdzēt, dot padomu, kas nogājis greizi?


function clean($value,$v=0,$w=96) {

$bb_replace = array(
$bb_replacements = array(
//'<a href="http://www.\\2.\\4" target="_blank" style="color:#987654;">www.\\2.\\4</a>',
'<a href="\\2" target="_blank" style="color:#987654;">\\4</a>',
'<a href="\\2" target="_blank" style="color:#987654;">\\2</a>',
'<img src="\\2" style="" alt="image" border="0" >',
'<div class="quoted_text"><span><b>\\2 rakstīja:</b></span><br>\\4</div>',
'<div class="quoted_text"><span><b>Citāts.</b></span><br>\\4</div>',
'<center style="margin:5px;"><object width="430" height="245"><param name="movie" value="http://www.youtube.com/v/\\2&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/\\2&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="430" height="245"></embed></object></center><br >',
'<font style="color:\\2;">\\4</font>',
'<font style="font-size:\\2;">\\4</font>',
'<font style="background-color:#E2E200;padding:1px;">\\2</font>',
'<a href="skype:\\2?chat">\\2</a>',
'<a href="mailto:\\2">\\2</a>'
$value = preg_replace($bb_replace, $bb_replacements, $value);
   if($v == 0) {
       $i = 0;
       $quotes = substr_count(strtolower($value),'[quote=');
       if($quotes == 1) {
           return preg_replace($bb_replace, $bb_replacements, $value);
       } else {
           while($i != $quotes) {
               if($i > 0) {
               $value = clean($value,1,$w);
           return $value;
   } else {
$value = preg_replace($bb_replace, $bb_replacements, $value);
return $value;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...