![]() |
Stripping line breaks from a string - ereg_replace & str_replace
I have a problem with a script in that the script saved line breaks between values that were saved. Well, the script was written that way for another purpose but now it is causing me issues...
I know I can take normal text like this and remove the /n's $myvalues = 'cars/ntrucks/nautomibiles'; Using code like this: $myvalues = ereg_replace('/n', '', $myvalues); HOWEVER, I do not know how to remove LINE BREAKS which I assume would be \n in the data? For example: PHP Code:
Quote:
EDIT to change the title to help someone else that may search this! |
It's \n and not /n... (backslash). And it should go between double quotes.
|
Quote:
I have also been trying to do the same thing with "str_replace" so I used that in my test code too. Here is my test code: PHP Code:
Quote:
|
Remove the "carriage return" characters as well.
PHP Code:
|
Quote:
Thank You, that was the problem! My Test Code: PHP Code:
Quote:
|
You're welcome. I'm happy to help. :)
|
You should use the Perl functions (preg) for regex rather than the PHP ones (ereg).
|
All times are GMT. The time now is 09:29 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|