formatting text in back office

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

formatting text in back office

Post by hame22 »

Hi all

I have an administration area to my site where users can input new values for a product.

The problem is that the text entered appears unformatted on my web pages.

What I would like to do is produce the facility to enclose text in paragraphs, make some bold and add links to this text.

Is there an easy way to do such a things?

thanks in advance
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Use nl2br to turn carriage returns (newlines) into <br /> tags. As regards making text bold, use a form of BBCode, such as the following:

Code: Select all

$bbcode = array('[b](.*?)[/b]' => '<b>\\1</b>'); //List of regex patterns & replacements

foreach ($bbcode as $pat => $rep) {
  $yourtext = preg_replace($pat, $rep, $yourtext);
}
Post Reply