Wait, its a different thing now. You see, I am trying to replace phpbb's bbcode with working html code, but what makes it hard is that phpbb inserts a number after SOME of the bbcode tags. Here is what I have so far:
function bbcodereplace($subject){
$search = array ("/\[url=(\W?)(.*?)(\W?)\](.*?)\[\/url\]/",
//     "/\[i(.*?)\](.*?)\[\/i(.*?)\]/",   // Italics
    "/\[u(.*?)\](.*?)\[\/u(.*?)\]/",   // Underline
    "/\[img(.*?)\](.*?)\[\/img(.*?)\]/",  // Image
    "/\[b(.*?)\](.*?)\[\/b(.*?)\]/");   // Bold
//                 '@&(gt|#62);@i',
//                 '@&(nbsp|#160);@i',
//                 '@&(iexcl|#161);@i',
//                 '@&(cent|#162);@i',
//                 '@&(pound|#163);@i',
//                 '@&(copy|#169);@i',
//                 '@&#(\d+);@e');                    // evaluate as php

$replace = array ('<a href="$2">$4</a>',
//         '<i>$2</i>',
        '<img src="$2">',
//                 '<u>',
//                 '<i>',
//                 '</u>',
//                 '</i>');
//                 '>',
//                 ' ',
//                 chr(161),
//                 chr(162),
//                 chr(163),
//                 chr(169),
//                 'chr(\1)');

return preg_replace($search, $replace, $subject);

my problem is that if I un-comment the italic thing, then image doesn't work. any idea on how to fix it? ----- Original Message ----- From: "John Hicks" <[EMAIL PROTECTED]>
To: "Nathan Heaps" <[EMAIL PROTECTED]>
Cc: <php-db@lists.php.net>
Sent: Wednesday, May 03, 2006 7:46 PM
Subject: Re: [PHP-DB] preg_replace help!

Nathan Heaps wrote:
I am trying to parse a forum post using php, but it parses it everytime it
sees the letter, not the thing in quotes.

What letter?  What thing in quotes?


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

Reply via email to