nl2el – A better alternative to PHP nl2br

I was used to use nl2br when showing some content with line brakes, but first time my requirement was to format that html code and applying some styles. So I was thinking about alternative of nl2br PHP function.

So, Here below is a simple and tiny function that accepts two arguments
1. Your text
2. HTML element you want to use.

nl2el – an nl2br Alternative

This function will add your own HTML element as well as you can give class name to it also. Thus this function can be used as an alternative of nl2br function. Hope this helps. 🙂

Shyam Makwana has written 21 articles

I am PHP developer with passion of exploring IT world for new technologies. I do projects in WordPress, Joomla, Magento, Drupal, Open Cart, Code Igniter, MVC and CorePHP. Checkout my about.me profile here http://about.me/shyammakwana to know more about me.