[PHP] and newlines under windows

2007-08-10 Thread Faither

Hey there!
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a "\n"-ewline.


I have a text string from a form and am trying to replace the "\n" or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the -tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the "\n" and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^

Thanks a lot in advance


Stefan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Faither

Stut wrote:

Faither wrote:
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a "\n"-ewline.


I have a text string from a form and am trying to replace the "\n" or 
chr(10) or however you might call the newline with a simple html break 
tag.


If I use the replacing functions I get the -tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array 
using:

 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the "\n" and chr(10).
This function ignored all newlines and gave me an array with one key 
and the entire text of the textarea as value Oh... and the 
newlines of course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^


First of all look at http://php.net/nl2br which does exactly what you're 
trying to do.


Second try this...

$string = str_replace("\r\n", '', $string);
$string = str_replace("\n", '', $string);

-Stut


Wee that helped a lot thanks for the fast reply!
And sorry for the spam... got time outs from my mail client so i send 
the e-mail again -.-'


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Getting a 'newline' out of a string

2007-08-10 Thread Faither

Hey there!
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a "\n"-ewline.


I have a text string from a form and am trying to replace the "\n" or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the -tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the "\n" and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^

Thanks a lot in advance


Stefan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Getting a 'newline' out of a string

2007-08-10 Thread Faither

Hey there!
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a "\n"-ewline.


I have a text string from a form and am trying to replace the "\n" or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the -tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the "\n" and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^

Thanks a lot in advance


Stefan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php