Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting rid of the actual return drop.. 1

Status
Not open for further replies.

unborn

Programmer
Joined
Jun 26, 2002
Messages
362
Location
US
i know about nl2br() but it doesnt seem to remove the actual drop. my friend is maken something ona one lined flat file, one line will be for each post topic item what ever but he has a multi lined textbox.. is there a way to totally remove the drop downs and replace them with <br>s?

thanks

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
[tt]$newstring = str_replace(&quot;\n&quot;, &quot;<br />&quot;, $string);[/tt]

//Daniel
 
weve tried that :/

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
>>drop downs?

i dont see why u need drop downs?

Known is handfull, Unknown is worldfull
 
I think what is being discused here are newlines/carriage returns.
You need to be aware that different operating systems have different character combinations.

It is entirely possible that you have a file that has newlines &quot;\n&quot; and carriage returns &quot;\r&quot;, thus it is the safest to remove both of them with a regular expression:
Code:
$newline = preg_replace(&quot;/(\n|\r)/&quot;,&quot;&quot;,$subject);

This should remove all &quot;\n&quot; and &quot;\r&quot;, no matter in what combination they appear.
 
thanks! my friend is VERY greatful and so am i .. good to know knowledge.. thanks again!

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
DRJ478:
shouldn't your regular expression also account for windows based systems which use both together, like &quot;\r\n&quot;?

I would suggest something like:

$newline = preg_replace(&quot;/(\n|\r|\r\n)/&quot;,&quot;&quot;,$subject);

 
It will, the expression in that syntax will replace all occurences of \n or \r. Hence, for \r\n, it's replacing the \r first, then the \n... if you were limiting to say, replace only once per line, then you'd be exactly correct.

-Rob

 
you're right skiflyer... :) thanks for pointing that out... didn't see the forrest for the trees :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top