Link to home
Start Free TrialLog in
Avatar of aot2002
aot2002

asked on

doesnt this get rid of newlines in a string ?

doesnt this get rid of newlines in a string ?


$string = ereg_replace ("\n", "", $string);

-->this is not working !!!    
$tmp= ereg_replace ("\n", "", $results2['DESC'][0]);

Avatar of sajuks
sajuks

try this way
$replace = array ("\n","\r");
$string = str_replace($replace,'',$string);
try this:

$string = ereg_replace("\r?\n", "", $string);

ASKER CERTIFIED SOLUTION
Avatar of nicholassolutions
nicholassolutions
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think it should be:
$tmp= ereg_replace ('\n', "", $results2['DESC'][0]); // simple quotes instead of double quotes

Georgiana
Maybe also try:

$string = ereg_replace (chr(13), "", $string);
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aot2002

ASKER

wow holy answers !
let me try these and get right back to you
Avatar of aot2002

ASKER

$parttypedesc = ereg_replace("\r?\n?", "", $results2['PART_TYPE_DESC'][0]);

This worked GREAT THANKS !
Avatar of aot2002

ASKER

Comment from gicutza_cj  feedback
Date: 09/30/2004 03:17AM EDT
 Comment  


I think it should be:
$tmp= ereg_replace ('\n', "", $results2['DESC'][0]); // simple quotes instead of double quotes

Georgiana


THIS DIDNT WORK i do know from experience that \n wont work in single quotes unless something has changed
You know that ereg is executed slower than str_replace is, although minimal it's something to keep in mind.

-r-
Avatar of aot2002

ASKER

thanks i didnt know this i always wondered why php site pointed everything to ereg not str_replace ?
are they removing str_replace ?
no. some people just think because ereg looks complicated, it looks impressive when they use it, I suppose.