Hi, I'm just starting in PHP.
I do have a problem with printing large textblock from a MYSQL database.
The text block contains dumps from buildlogs and should look like:
Configure:
- AIPSPATH not set and no explicit path is given
for: DMI, StationSim, CEP/CPA/OCTOPUSSY, CEP/CPA/UVD
Make all:
see configure.... could not compile packages DMI, StationSim, CEP/CPA/OCTOPUSSY, CEP/CPA/UVD
Make check:
see configure..
(this one was viewed in MySQL-Front)
However when I use the following code (as adviced in the books I use):
echo "<strong><br>Test Summary: </strong>";
echo htmlspecialchars( stripslashes($row["Summary"]));
it looks like :
Test Summary: Configure: - AIPSPATH not set and no explicit path is given for: DMI, StationSim, CEP/CPA/OCTOPUSSY, CEP/CPA/UVD Make all: see configure.... could not compile packages DMI, StationSim, CEP/CPA/OCTOPUSSY, CEP/CPA/UVD Make check: see configure..
so it looks like the newlines aren't printed.
Is there a solution for this ( I really like to have the newlines. Because thsi part was rather small, usually I have 100's of lines in that block.)
Thanx in advance
Question about printing newlines in text blocks (newbie)
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Simple:
Say you get the text block out of the DB and set it as the variable $text:
Then echo $text out, and it has line breaks!
later on, -Brian.
Say you get the text block out of the DB and set it as the variable $text:
Code: Select all
$search = array("/\n/");
$replace = array("<br />\n");
$text = preg_replace($search, $replace, $text);later on, -Brian.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You really don't need to do all of the regular expression stuff, nl2br() is a built in function which will put HTML line breaks in where there are newlines.
Mac
Mac