user3681491
user3681491

Reputation:

PHP/MySQL Query not saving data in database

I have this data in a database:

http://pastebin.com/wdgj3aTr

I am able to show plain text using this PHP function:

if(!function_exists("dropHtmlTags")) {
    function dropHtmlTags($string) {
        // remove html tags
        $string = strip_tags($string, ' \r\n\t');

        return $string;
    }
}

but i want to keep the line breaks when displaying, how can i do this?

UPDATED CODE

if(!function_exists("dropHtmlTags")) {
    function dropHtmlTags($string) {
        // remove html tags
        $string = strip_tags($string, ' \r\n\t');

        return nl2br($string);
    }
}

Upvotes: 1

Views: 91

Answers (2)

prava
prava

Reputation: 3986

if(!function_exists("dropHtmlTags")) {
    function dropHtmlTags($string) {
        // remove html tags
        $string = strip_tags($string, ' \r\n\t'); 
        echo nl2br($string);
    }
}

Upvotes: 1

Pinoniq
Pinoniq

Reputation: 1385

Instead of stripping the \n (new line) replace it with <br />

Other possibility, don't strip the \n and wrap everything in <pre></pre>

Upvotes: 1

Related Questions