What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help! =P

PHP help! =P
Author: Message:
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
O.P. PHP help! =P
Ok guys I need your brains once again, ya ya.

Let's say I have this html:

<h1>boobs</h1>
<br />
<br />

It is all nice and dandy, and real good having boobs in big letters but I want to show it as:

<h1>boobs</h1><br /><br />

When it is excuted. So is there a way to remove using a function in PHP all the lines spacing and keep all my html on one line? :P

If anyone can help I would be very greatful :)
04-06-2006 05:31 PM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP help! =P
Making it harder to read/steal, eh? :dodgy:

You could simply strip out all the line break characters (\n and \r)...

$source = str_replace(array("\n", "\r"), "", $source);

Of course, that may cause problems if you need line breaks in your code (like for a <textarea> or <pre>). Also, any tabs or spaces used for indenting would still remain... you could probably use a regexp to get rid of those...
04-06-2006 05:41 PM
Profile PM Web Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
O.P. RE: PHP help! =P
$destorylines = array("\n", "\r");
$showstory = str_replace($destorylines, "", "$story");

Thanks wdz I got it working great. I don't like using str_replace but it  seems to be the only way :P
04-06-2006 06:25 PM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP help! =P
What's wrong with str_replace()? :o

What kind of method did you have in mind? :p
04-06-2006 06:30 PM
Profile PM Web Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
O.P. RE: PHP help! =P
quote:
Originally posted by WDZ
What kind of method did you have in mind? (Smilie)



Something to add it to the database before hand and not change the code excuted, but I can work with this :P
04-06-2006 06:39 PM
Profile PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
34 / Male / –
Joined: Jun 2004
RE: PHP help! =P
quote:
Originally posted by Absorbation
quote:
Originally posted by WDZ
What kind of method did you have in mind? (Smilie)



Something to add it to the database before hand and not change the code excuted, but I can work with this :P
Then you can just use the str_replace on the string you insert into the database :-/
oh and btw, you don't need the quotes around $story :P
04-06-2006 06:43 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On