$text=preg_replace("#\[([bisu])\](.*?)\[/\\1\]#i","<\\1>\\2</\\1>",$text);
"Dz" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Hello,
>
> I found one minimalistic BBcode script, but it doesnt work.
>
> Warning: Unknown modifier '1' in f:\_php\_f\bb-code\test.php on line 32
>
> line 32 is such:
>
> $t = preg_replace_callback( '/[('.$atag.')(=(.*))?](.*)[/1]/isU', 'nc',
$s);
>
> How to get work it?
>
>
>
> Source is only 40 lines:
>
> <?php
>
> $tagid = array(
>     'b' => '<b>%s</b>',
>     'u' => '<u>%s</u>',
>     'i' => '<i>%s</i>',
>     'tsitaat' =>
'<blockquote><small><b>Tsitaat</b>:<hr>%s<hr></small></blockquote>',
>     'url' => '<a href="%s">%s</a>',
>     'mail' => '<a href="mailto:%s";>%s</a>',
>     'img' => '<img src="%s" alt="%s">',
>     'code' => '<font color="green">%s</font>',
>     'kood' => '<font color="green">%s</font>',
>     'color' => '<font color="%s">%s</font>',
>     'size' => '<font size="%s">%s</font>'
> );
> $atag = join( '|', array_keys( $tagid));
>
> /*
> print '<p>allowed tags:</p>';
> foreach( $tagid as $key => $value) {
> echo "<b>$key</b><br>n";
> }
> */
>
> function nc( $s){
> if ( $s[1] ) $s[4] = nk( $s[4]);
> global $tagid;
> return
$s[1]?sprintf($tagid[$s[1]],(!empty($s[3])?$s[3]:$s[4]),$s[4]):$s[0];
> }
> function nk( $s){
> global $atag;
> $t = preg_replace_callback( '/[('.$atag.')(=(.*))?](.*)[/1]/isU', 'nc',
$s);
> return $t;
> }
>
> $text = "[b]bold text [i]mixed with[/b] italic[/i]";
> echo nl2br( nk( htmlspecialchars( $text, ENT_NOQUOTES)));
>
> ?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to