Re: Getting a 'newline' out of a string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/07, Daniel Brown <parasane@xxxxxxxxx> wrote:
> On 8/10/07, Faither <Faither@xxxxxx> wrote:
> > 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 <br>-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. -
> > <br>-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
> >
> >
>
>    If I'm not mistaken, Windows doesn't strictly use \n, but rather \r\n.
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>

Just to clarify, the DEFAULT line-endings for OSes:
Windows: \r\n (carriage return followed by a newline)
Unix: \n (newline)
Mac: \r (carriage return)

Of course it is possible to use other line endings on those OSes, but
these are the default.

Tijnema
-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux