[FX.php List] Line breaks in text fields

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Mon Jul 10 16:48:13 MDT 2006


On 11/7/06 2:28 AM, "Derrick Fogle" <derrick at fogles.net> wrote:

> I've been using the FM GetAsCSS() function with some success;
> creating a calculated field that equals getascss(sourcefield) and
> using that field for PHP output renders the line breaks, bold, italic
> and basic formatting pretty well.
> 
> Otherwise, you've got to use the str_replace(), with the search for
> Vertical Tab (ASCII 11) and replace with whatever in PHP.
> 

Here's a function I wrote to deal with this issue and produce valid code at
the same time:

// function to replace line breaks in FM output with <br /> or <p> elements
function formatDesc($input)
{
    $br = chr(10); // single line feed character (LF)
    $p = "<br />\n<br />\n";
    $badChars = array($p, "& ");
    $goodChars = array("</p>\n\t\t<p>", "&amp; ");
    $text = str_replace($br, "<br />\n", $input); // replace LF with <br />
    $description = str_replace($badChars, $goodChars, $text);
    echo "<p>" . $description . "</p>\n";
}

-- 
Kevin Futter
Webmaster, St. Bernard's College
http://www.sbc.melb.catholic.edu.au/



------------------------------------------
This e-mail and any attachments may be confidential.  You must not disclose or use the information in this e-mail if you are not the intended recipient.  If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies.  The College does not guarantee that this e-mail is virus or error free.  The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not.  The content and opinions in this e-mail are not necessarily those of the College.




More information about the FX.php_List mailing list