Page 1 of 1

Extracting "breaklines" from html source

Posted: Wed Apr 19, 2006 7:07 pm
by IonutZ
Hey guys,


Basically if anyone has any idea how to do this ::

Code: Select all

4/4/2006 11:02 AM

Heyyyy
to

Code: Select all

4/4/2006 11:02 AM
Heyyyy
This would be done in a string which is then echoed for output... I've tried str_replace but no luck :(

Any ideas guys?

Thanks,

IonutZ

Posted: Wed Apr 19, 2006 7:44 pm
by method_man
ummmm get rid of the <br>?

Posted: Wed Apr 19, 2006 7:49 pm
by IonutZ
There is no <br>

The text shown up there is how its shown in View Source...

Now I need to load this text into Flash and therefore any break in the code (is like pressing enter in word) and it shows up bad :|

Posted: Wed Apr 19, 2006 7:59 pm
by John Cartwright
windows = \n\r

linux = \n



a str_replace() should work

Posted: Wed Apr 19, 2006 8:08 pm
by IonutZ

Code: Select all

$myContent = str_replace('\n', '', $myContent);
$myContent = str_replace("\n", "", $myContent);
Those two don't do it :(

Code: Select all

4/4/2006 11:02 AM

Thanks
< still there

You can look at the output of the script ::

http://ionutz.biz/myspace/comments.php

If you look at the source you'll see what I'm saying...

Thanks

Posted: Wed Apr 19, 2006 8:31 pm
by RobertGonzalez
You need to check for "\n", "\r" and "\n\r". Do a str_replace of all of those with an empty string and it should put you on the right track (although it will eliminate all line feeds, including the one that would give you the break you actually want). But play with it. I'm sure you'll figure it out.

Posted: Wed Apr 19, 2006 8:45 pm
by IonutZ
haha works :) ! 10x