How do you replace white space that you are pulling from the DB and add <BR> so text displays properly with spaces? The <pre> tag does this but now my text word wrapped far to the right.
you can replace whitespacing using trim(), ltrim, rtrim() or str_replace() dependant on what you are looking to replace.
For converting newlines to breaks, use nl2br()
Have a look at the manual for more info.
would this be what I'm looking to do?
$space = str_replace('\r\n','<br>', $space);
well nl2br() does exactly that for you. It converts new lines to breaks. So you could simply change your code to:
print nl2br($space);
For trimming whitespace, if you're just looking to trim any extra space at the beginning and end of the string, use trim. You can even combine the two into
print nl2br(trim($space));
Now I understand the concept. Below is my code echoing...Now I confused as where to place what we disscussed above. Sorry me a NOOB
GOT IT! Sorry for not thinking properly... 🙁
print nl2br ("
<!-- Printing job details --> <b>Vacancy Announcement Number:</b> $jcode <P> <b>Posted on:</b> $posted <p> <b>Opening Date:</b> $opening_date <p> <b>Closing Date:</b> <font color=red>$closing_date</font> <p> <b>Designation:</b> $designation <p> <b>Series & Grade:</b> $series_grade <p> <b>Promotion Potential:</b> $promotion <p> <b>Salary:</b> $salary <p> <b>Location:</b> $location <a href=?cmd=Apply&jcode=$jcode title='Apply online.'>Apply online</a> for this job, or <a href=?cmd=Upload&jcode=$jcode title='Must be a MS WORD document. The name of the word doc must be your name. i.e Thomas H Sasse.doc'>Upload a Resume for this job.</a> You can also <a href=?cmd=List title= 'Return to job listings.'>return to job listings</a>");