Question: I have to render some text to a web page. The text is coming from sources outside my control and it is formatted using newlines and tab characters.

New lines `(\n)` can be replaced by `br` tags, but what about preserving tabs? A brief search reveals there is no way to directly render tab characters in HTML.

Answer: 
An alternative to the non-breaking space would be the em space (`&emsp;` or `&#x2003;`). It is usually rendered as a longer space, if that is an advantage.
If you're already replacing line breaks, why not do the same for tabs...?

```
str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $text);

```