Jump to content

Help with nl2br()


EchoFool

Recommended Posts

Hey,

 

When a user posts a message the next page shows it as a preview before confirming.... but for some reason the nl2br function doesn't work...

 

 

This is what i have:

 

<?php
function local($BB){
//bb code fucntion
                    $BBCode = array(
                    "&" => "&",
                    "[title]" => '<center><span class="header">',
                    "[/title]" => '</span></center>',
                    "[p]" => '<p align"left">',
                    "[/p]" => '</p><br><br>',
                    "[i]" => '<i>',
                    "[/i]" => '</i>',
                    "[b]" => '<b>',
                    "[/b]" => '</b>'
                        
                        );
                    
                    $Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB);
                return $Message;
}


    $Message = SQLskip($_POST['letter']);
?>

    <span class="Negative"><blink>NOTE:</blink> This is just a preview!</span><br><br>
    <div id="messagebox"><br><br>
    <?php echo nl2br(local($Message));?>
    <br><br>
    </div>

But the page shows : test\r\n\r\ntest

 

Any idea why?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/205112-help-with-nl2br/
Share on other sites

Kind of hard to decypher what the problem is when a) I have no clue what you are using as an input for testing and b) you are invoking a function called SQLskip() which isn't displayed here. For all I know the problem is with that function.

 

I'm too lazy to test, but there is an error in your BB code parser. I doubt it is the cause of your problem, but who knows.

 

This

"[p]" => '<p align"left">',

 

Should be this

"[p]" => '<p align="left">',

Link to comment
https://forums.phpfreaks.com/topic/205112-help-with-nl2br/#findComment-1074267
Share on other sites

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.