Extracting "breaklines" from html source

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
IonutZ
Forum Newbie
Posts: 4
Joined: Wed Apr 19, 2006 7:04 pm
Location: Troy, MI
Contact:

Extracting "breaklines" from html source

Post 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
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

ummmm get rid of the <br>?
IonutZ
Forum Newbie
Posts: 4
Joined: Wed Apr 19, 2006 7:04 pm
Location: Troy, MI
Contact:

Post 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 :|
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

windows = \n\r

linux = \n



a str_replace() should work
IonutZ
Forum Newbie
Posts: 4
Joined: Wed Apr 19, 2006 7:04 pm
Location: Troy, MI
Contact:

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
IonutZ
Forum Newbie
Posts: 4
Joined: Wed Apr 19, 2006 7:04 pm
Location: Troy, MI
Contact:

Post by IonutZ »

haha works :) ! 10x
Post Reply