Shoutbox

PHP help! =P - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: PHP help! =P (/showthread.php?tid=57924)

PHP help! =P by absorbation on 04-06-2006 at 05:31 PM

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 :)


RE: PHP help! =P by WDZ on 04-06-2006 at 05:41 PM

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...


RE: PHP help! =P by absorbation on 04-06-2006 at 06:25 PM

$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


RE: PHP help! =P by WDZ on 04-06-2006 at 06:30 PM

What's wrong with str_replace()? :o

What kind of method did you have in mind? :p


RE: PHP help! =P by absorbation on 04-06-2006 at 06:39 PM

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
RE: PHP help! =P by Plik on 04-06-2006 at 06:43 PM

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