FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » replacing spaces with newline
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: replacing spaces with newline [message #181312 is a reply to message #181307] Sat, 04 May 2013 12:24 Go to previous messageGo to previous message
Jeff North is currently offline  Jeff North
Messages: 58
Registered: November 2010
Karma:
Member
On Sat, 4 May 2013 04:09:06 -0700 (PDT), in comp.lang.php Simon Hall
<hall(dot)simon82(at)gmail(dot)com>
<6964ae80-5d55-44bf-984e-9277b42fc67d(at)googlegroups(dot)com> wrote:

> | Hi Guys,
> |
> | I am new to PHP and I am trying to clean up some text, what I am looking to do is to create a new line at each space, I have tried the following but it still outputs with just spaces.
> |
> | <?php
> |
> | $file = file_get_contents("mytext.txt");
> |
> | $file = Str_replace(" ", "\r\n", $file);
> |
> | echo $file;
> |
> | ?>
> |
> | Any ideas?

If you are outputting to html then the \r\n are ignored so you could
use: echo nl2br( $file );
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: take two - fetch items from a row.
Next Topic: Unique array of arrays - how can I do this?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 06:42:50 GMT 2024

Total time taken to generate the page: 0.03967 seconds