Jump to content

[SOLVED] Parser not working...


Aureole

Recommended Posts

Anyone have any idea why this isn't working?

 

<?php
function parse($input) {
    $output = nl2br($input);
$output = stripslashes($input);
$output = preg_replace("`\[b\](.*)\[/b\]`sUi","<strong>\\1</strong>",$input);
$output = preg_replace("`\[i\](.*)\[/i\]`sUi","<em>\\1</em>",$input);
$output = preg_replace("`\[u\](.*)\[/u\]`sUi","<u>\\1</u>",$input);
$output = preg_replace("`\[url\]([\w]*[:\/\/]*[\w\.\?\/&=\:;, \-@%\?]+)\[/url\]`sUi","<a href='\\1'>\\1</a>",$input);
$output = preg_replace("`\[url\=([\w]*[:\/\/]*[\w\.\?\/&=\:;, \-@%\?]+)\](.*)\[/url\]`sUi","<a href='\\1'>\\2</a>",$input);
$output = preg_replace("`\[img\]([\w]*[:\/\/]*[\w\.\?\/&=\;, \-@%\?]+)\[/img\]`isU","<img src='\\1' alt='Image' />",$input);
return $output;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/72512-solved-parser-not-working/
Share on other sites

Give this a try

 

<?php
function parse($input) {
    $output = nl2br($input);
$output = stripslashes($output);
$output = preg_replace("`\[b\](.*)\[/b\]`sUi","<strong>\\1</strong>",$output);
$output = preg_replace("`\[i\](.*)\[/i\]`sUi","<em>\\1</em>",$output);
$output = preg_replace("`\[u\](.*)\[/u\]`sUi","<u>\\1</u>",$output);
$output = preg_replace("`\[url\]([\w]*[:\/\/]*[\w\.\?\/&=\:;, \-@%\?]+)\[/url\]`sUi","<a href='\\1'>\\1</a>",$output);
$output = preg_replace("`\[url\=([\w]*[:\/\/]*[\w\.\?\/&=\:;, \-@%\?]+)\](.*)\[/url\]`sUi","<a href='\\1'>\\2</a>",$output);
$output = preg_replace("`\[img\]([\w]*[:\/\/]*[\w\.\?\/&=\;, \-@%\?]+)\[/img\]`isU","<img src='\\1' alt='Image' />",$output);
return $output;
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.