Aureole Posted October 9, 2007 Share Posted October 9, 2007 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 More sharing options...
pocobueno1388 Posted October 9, 2007 Share Posted October 9, 2007 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; } ?> Link to comment https://forums.phpfreaks.com/topic/72512-solved-parser-not-working/#findComment-365638 Share on other sites More sharing options...
Aureole Posted October 9, 2007 Author Share Posted October 9, 2007 Thanks! Link to comment https://forums.phpfreaks.com/topic/72512-solved-parser-not-working/#findComment-365650 Share on other sites More sharing options...
pocobueno1388 Posted October 9, 2007 Share Posted October 9, 2007 You just had to change all the $input variables to $output, to keep the variable changing. Don't forget to solve. Link to comment https://forums.phpfreaks.com/topic/72512-solved-parser-not-working/#findComment-365652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.