trouble creating bbcode [php][/php]<

liunx

Guest
hi im creating something similiar wo the \[php\] and \[/php\] function.

here what i ahve so far:
PHP:
eregi ("(.*)\[ *php *\]([^\[]*)\[ */ *php *\](.*)", $row[msg], $msg);
$msg = $msg[1]."<div style=\"margin-left:20;width:75%\"><font size=\"1\">PHP:</font><hr>".highlight_string($msg[2], TRUE)."<hr></div>".$msg[3];
PHP] 

this work as long as user only uses \[php\] and \[/php\] ONCE.

i guess there must be some looping involved wich will prollly who other code. if anyone can help me or point me to a post/thread that covers this subject that would be greatwhy have the (.*) on each side of your patern?i got that from a other thread, im not goood at that sutff.<?php
function transform($matches) {
   return '<div style="margin-left:20;width:75%"><font size="1">PHP:</font><hr>'.highlight_string($matches[1],TRUE).'<hr></div>';
  }

$new_msg = preg_replace_callback('/\\\[php\\\](.*?)\\\[\\\/php\\\]/msi','transform', $msg);
?>
 
Back
Top