• toto

    (@toto)


    Hi friends if there is no new lines formated you can use for your variable PHP Autoformat Paragraph tags.

    See here: http://stackoverflow.com/questions/5240729/php-autoformat-paragraph-tags

    $text = "hello, I am text
    
    and this is another paragraph, please do some cool
    stuff with this (this is after a  line break)
    
    last apragrahp...";
    
    $text = str_replace("\r\n","\n",$text);
    
    $paragraphs = preg_split("/[\n]{2,}/",$text);
    foreach ($paragraphs as $key => $p) {
        $paragraphs[$key] = "<p>".str_replace("\n","<br />",$paragraphs[$key])."</p>";
    }
    
    $text = implode("", $paragraphs);
    
    echo $text;
  • The topic ‘No paragraphs and line break’ is closed to new replies.