Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

64 users online



If you'd like to have BBcode on your shoutbox.

If you'd like to have BBcode on your shoutbox.

Currently viewing this thread: 1 (0 members and 1 guests)


Page 3 out of 3
CONFIQ

CONFIQ

Status: Offline!

I did it Smile

PHP:

<?php
$str 
preg_replace("/(\[B\])(.+)(\[\/B\])/iUs","<b>\\2</b>",$str);
?>

P.S.U'll need to quote me to see the code

CONFIQ

CONFIQ

Status: Offline!

here is all code Wink

PHP:

<?php
 $str 
preg_replace("/(\[b\])(.+)(\[\/b\])/iUs","<b>\\2</b>",$str);
 
$str preg_replace("/(\[i\])(.+)(\[\/i\])/iUs","<i>\\2</i>",$str);
 
$str preg_replace("/(\[u\])(.+)(\[\/u\])/iUs","<u>\\2</u>",$str);
 
$str preg_replace("/(\[url\])((http|ftp|https|news|gopher|wais):\/\/.+)(\[\/url\])/iU","<a href='\\2' target='_blank'>\\2</a>",$str);
 
$str preg_replace("/(\[url=((http|ftp|https|news|gopher|wais):\/\/.+)\])(.+)(\[\/url\])/iU","<a href='\\2' target='_target'>\\4</a>",$str);
 
$str preg_replace("/(\[color=(.+)\])(.+)(\[\/color\])/iUs","<font color='\\2'>\\3</font>",$str);
 
$str preg_replace("/(\[email\])(.+)(\[\/email\])/iU","<a href='mailto:\\2'>\\2</a>",$str);
 
$str preg_replace("/(\[email=(.+)\])(.+)(\[\/email\])/iU","<a href='mailto:\\2'>\\3</a>",$str);
 
$str preg_replace("/(\[img\])((http|ftp|https):\/\/.+)(\[\/img\])/iU","<img src='\\2' alt='bzvze'>",$str);
?>

Lane

Lane

Status: Offline!

how would i go about making a bbcode that highlights php syntax similar to what there is here...

TrigBoy

TrigBoy

Status: Offline!
Quote:

Originally posted by Adman

PHP:


<?PHP
//Cdude, Recessive, and me
//Highlights php code like vB
function PHPCode($str) {
    
preg_match_all('/(\[PHP\])(.+?)(\[\/PHP\])/si',$str,$match);
    
$codes $match[2];
    foreach(
$codes as $i => $c){
        
$a $match[1][$i];
        
$b $match[3][$i];
        if(
"<?" == substr($c02)){
            
$str str_replace("$a$c$b",highlight_string("\n\n".$c."\n\n"TRUE),$str);
        } else {
            
$str str_replace("$a$c$b",highlight_string("\n\n<?php\n\n".$c."\n\n?>\n\n"TRUE),$str);
        }
    }
    
    return 
$str;
}
?>

xMattHawkx

xMattHawkx

Status: Offline!

Thanks for the excellent thread CDude! I've run into a small problem though - when using this code on a string that includes multiple instances of a tag, the expression retrieves everything inside the VERY first and VERY last tag, and works its way inward. Does anyone know how to fix this, so it goes one set of tags at a time?

Thanks!

___________________

- Matt

BigToach

BigToach

Neversidian
Status: Offline!

heres why
change

PHP:

<?php

$bold 
'/(\[ b\])(.+)(\[\/b\])/'

?>


to.......

PHP:

<?php

$bold 
'/(\[ b\])(.+?)(\[\/b\])/'// notice the question mark

?>


and it will work for yah

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

Last edited by BigToach, January 22nd, 2003 10:44 PM (Edited 1 times)

Page 3 out of 3
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0103 seconds.