PHP Function to replace all new line characters in a string with BR tag

There is an incredible but little known built-in function with PHP that replaces all new line characters within a string with html <br /> tags. Its perfect if you ever want to display the contents of a text area within HTML.

$str = nl2br($str);

This will replace all new line characters with valid XHTML <br /> tags.

There is also an optional parameter to turn of XHTML and just use traditional <br> tags.

$str = nl2br($str, false)

Bee Keeping Course

Alistair Jinks shares some of his experience when attending a beginners bee keeping course at the local Roe Valley club.

“I was surprised when my wife gave me this course as a Christmas present. Whilst I was pleased at her kindness, I was not sure what to expect. Would it be oral, written or practical? What sort of people teach about bees? What type of people go along? Would I fit in and like learning about bees?

The course was GREAT! It lasted over 10 to 12 weeks. The people teaching and attending came from all sorts of walks of life and were all really pleasant and welcoming. The theory material was a little daunting at the start with so much fascinating facts to learn in the evening after work but it was all good stuff. After the half way point practical sessions were given with all the safety gear provided. Even though I was nervous the best experience was seeing the bees in their hive.  It was fantastic!

I am very grateful to the teachers and the “students” of the Roe Valley club and would recommend anyone to go along and take the option of a short exam at the end in both the theory and practical aspects of keeping bees. It helps focus the mind!”