Gossamer Forum
Home : General : Internet Technologies :

ereg_replace() not getting rid of newlines :|

Quote Reply
ereg_replace() not getting rid of newlines :|
Mmm....the following code does not seem to be working;

$cut[1] = ereg_replace("\n","",$cut[1]);

I'm trying to get rid of newlines from $cut[1]. I'm *sure* this code has worked before with me Unsure

Anyone who knows PHP got any ideas?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
Try it with preg_replace and see what happens. That should at least tell you if it has something to do with the content of $cut[1] or with your use of the ereg_replace function.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] ereg_replace() not getting rid of newlines :| In reply to
Tried it with pre_replace too Frown I *know* there is a newline in there though, because the following code;

echo "<select name=county value=\"$cut[1]\">$cut[1]</select>";

...gives....

<select name=county value="test
">
test
</select>

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
So then use rtrim Crazy
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
Wow...I didn't even know that function existed. It worked like a charm Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
I know sweet FA about php and it took one search on yahoo to find it.
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
Trying to replicate your search produced some *evil* results. Check this function out:

nl2br()

Like, what the hell is PHP all about? No wonder that scriptkiddies use it, that function just makes me want to jump up and say:

ASL@!@! AOL!!! L33T!

- wil
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
Whats wrong with the nl2br() function? Its quite handy.

Code:
<?

$val = "test
var
can
be
found
here";

echo nl2br($val);

// ....or....

$show = ereg_replace("\n","",$val);

?>

I literally just used that function in a script I am working on now. I grabbed some data from a MySQL table, and it was only seperated by newlines. A simple nl2br() call, and I had a nicely formatted field ready to be shown in the browser Smile

>>> No wonder that scriptkiddies use it<<<

You saying something? GT, me, and millions of other users? Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
It's just the way the function is named. The use of '2' instead of writing 'to' similar to children's SMS language these days, closely associated with AOL "hackers" and scriptkiddies. Horrible, horrible, horrible. Saying that, I'm not a fan of Java's naming convention which would have been, in this case, called 'NlToBr' which is arguably worse.

- wil
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
Its more the case of not being enough function calls available. Also, it is easier to read nl2br(), than nltobr(), right?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
Perl programmers don't need lots of "basic" functions to do tasks for them, we use the good old manual approach with a regex or internal function.

I bet php programmers can't overload operators such as +, <=>, cmp like we can Tongue

Last edited by:

Paul: Jun 12, 2003, 8:20 AM
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
Umm, no, only if you're in the "texting/sms" generation. You should nl2br to a veteran 40 year old programmer and they'll look at you like you're insane, what does the "2" mean? Oh, it "nl" a "br" * 2? It does the function twice? What? It's stupid and annoying. But then again, I have a big issue with anyone texting me something like 'wot r u up 2 m8'. I just delete the message with great frustration. Just because there's a new medium to contact someone, why should we change and erode our language?

- wil
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
Laugh Well, good thing you don't program PHP then :p

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
Quote:
why should we change and erode our language?

Because SMS messages can only handle about 80 characters Wink

I'm sure:

how r u m8

...is better than..

Hello Wil, how ar..
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
Not true:

http://ca2.php.net/...ion.ereg-replace.php

http://ca2.php.net/...ion.preg-replace.php

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] ereg_replace() not getting rid of newlines :| In reply to
What are you referring to?
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
The versatility and robustness of regex in PHP in general, using the ereg and preg functions.

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] ereg_replace() not getting rid of newlines :| In reply to
I never questioned the power of php regexs. I mentioned overloading which is a different subject.

Last edited by:

Paul: Jun 12, 2003, 9:58 AM
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
My bad, I misread your posting. Need my morning caffeine fix - read diet coke =)

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
Actually, the limit for SMS on UK networks is 160 characters.

- wil
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
In Reply To:
Actually, the limit for SMS on UK networks is 160 characters.

Depends if sending online, or from a mobile Tongue (I know I'm being picky)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] ereg_replace() not getting rid of newlines :| In reply to
The exact number doesn't really matter. The point is still the same. In order to send someone a message via sms it's easier and quicker to abbreviate words or spell them phonetically.
Quote Reply
Re: [Paul] ereg_replace() not getting rid of newlines :| In reply to
No it's not.

It's easier to send someone abbreviated letter, airmail, fax, email, telemessage, telegram, etc. etc. etc.

Why should we give up our English for the sake of a SMS message?

- wil
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
1) You have poor reception, are out in the middle of no-where, and you need to let someone know what is happening.

2) You are out and about, and you don't have Radio in your car. Your mate wants to send you a SMS to let you know the football score..

3) SMS can be sent in a few minutes, whilst airmail/letter takes ages. Fax, Email and Telephone are different matters.... but maybe they don't want to have to talk to the person? Wink

4) Kiids want to chat to their mates in lessons, so they send SMS's to each other, and can reply. I don't think they would get away with verbally chatting away on their phone Tongue

Just a few reasons why SMS's are good. I don't know where I would be in this day and age without them.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Wil] ereg_replace() not getting rid of newlines :| In reply to
Oh, and who said anything about "giving up" the English language? Are we not using it now, in this thread? Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!