public function p2br($data)
    {
        // Remove opening <p> tags
        $data = preg_replace('#<p[^>]*?>#', '', $data);

        // Remove trailing </p> to prevent it to be replaced with unneeded <br />
        $data = preg_replace('#</p>$#', '', $data);

        // Replace each end of paragraph with two <br />
        $data = str_replace('</p>', '<br /><br />', $data);

        return $data;
    }
public function p2br($data)
    {
        // Remove opening <p> tags
        $data = preg_replace('#<p[^>]*?>#', '', $data);

        // Remove trailing </p> to prevent it to be replaced with unneeded <br />
        $data = preg_replace('#</p>$#', '', $data);

        // Replace each end of paragraph with two <br />
        $data = str_replace('</p>', '<br /><br />', $data);

        return $data;
    }
public function p2br ( $ data ) { // Remove opening <p> tags $ data = preg_replace ( '#<p[^>]*?>#' , '' , $ data ) ; // Remove trailing </p> to prevent it to be replaced with unneeded <br /> $ data = preg_replace ( '#</p>$#' , '' , $ data ) ; // Replace each end of paragraph with two <br /> $ data = str_replace ( '</p>' , '<br /><br />' , $ data ) ; return $ data ; }
Replaces paragraph formatting with double linebreaks.

Example: '<p>This is a text.</p><p>This should be another paragraph.</p>'
Output:  'This is a text.<br /><br>This should be another paragraph.'

@param   string  $data   Text to format.
@return  string          Formatted text.
Replaces paragraph formatting with double linebreaks .