say a string has "\n" in it. to be more specific --- a text area is submited with newlines breaks in it (by hitting the `enter` key). is there any way to replace those lines break with a html <br/> tag? if not, any one know how to parse xml files with a content that has line breaks in it?---->
ex:
<xmlTag> Info Info Info //line break
info info info info //line break
info info info</xmlTag>
because if i parse this right here, i will only get the top line of info.
if still confusing i can explain more. thnx
string replace
Moderator: General Moderators
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
Anyone know off hand whether nl2br() just does what macewan said ?
Like this:
Like this:
Code: Select all
<?php
function nl2br($string)
{
$string = preg_replace("/(\015\012)|(\015)|(\012)/","<br /> ",$string);
return $string;
}
$text = "Blah\nBlahBlah\nBLAH!";
print nl2br($text);
?>