united states of america usa  linkedinfacebookgoogle
Line break to p (paragraph) tag conversion

phpThere's a nl2br function in PHP, below is a function to convert line breaks to <p> tags:

(We did not write this, but have found it to be useful):

 

function nl2p($string, $line_breaks = true, $xml = true) {
$string = str_replace(array('<p>', '</p>', '<br>', '<br />'), '', $string);
// It is conceivable that people might still want single line-breaks
// without breaking into a new paragraph.
if ($line_breaks == true)
    return '<p>'.preg_replace(array("/([\n]{2,})/i", "/([^>])\n([^<])/i"), array("</p>\n<p>", '$1<br'.($xml == true ? ' /' : '').'>$2'), trim($string)).'</p>';
else
    return '<p>'.preg_replace(
    array("/([\n]{2,})/i", "/([\r\n]{3,})/i","/([^>])\n([^<])/i"),
    array("</p>\n<p>", "</p>\n<p>", '$1<br'.($xml == true ? ' /' : '').'>$2'),
    trim($string)).'</p>';
}

 

ALT Rotate Plugin for Joomla

Description

joomlaJoomla 3+ plugin for displaying one type of content for registered users and another type of content for guests within an article.

Usage

Content can be displayed inline or using a module:

Using Inline content
Guests will see the content within these tags {guest}{/guest}.

Example: {guest}content to display{/guest}
Will show for guests: content to display

and Registered users will see the content within these tags {registered}{/registered}.

Example: {registered}content to display{/registered}
Will show for registered users: content to display

Using Modules
To include content for Guests, use will see this:
{displayguest modulename}

To include content for Registered users, use this:
{displayreg modulename}

Where "modulename" is the custom module.

Continue Reading

Tel: (786) 646-6461   |   Toll-Free: (877) 454-0758
18350 NW 2nd Ave, Suite 406E, Miami, FL, 33169, USA
Privacy Policy