On 10/11/2011 10:44 AM, ad...@buskirkgraphics.com wrote:

Richard L. Buskirk
Senior Software Engineer/Systems Administrator

You can’t grow your business with systems that are on life support...

-----Original Message-----
From: Al [mailto:n...@ridersite.org]
Sent: Tuesday, October 11, 2011 10:17 AM
To: php-general@lists.php.net
Subject: [PHP] Re: newline and return issues in string

On 10/11/2011 7:58 AM, ad...@buskirkgraphics.com wrote:
I have come across an issue with my string that I would like to find
faster way to resolve.

It seems there are new lines and returns at different positions of

First I exploded on the new line explode(“\n”, $ string)

This gave me a nice array but when I try to implode I get the new

There is not a consistent position and there seems to be some hidden
in the array as well.

Is there a way, or has someone written a filter that would allow me
remove all the newlines and returns from the array or string.

Understand I have resolved this issue but I think I have to be going
this the hard way because it is just too complex .


$filter = array("\r\n", "\n", "\r");

str_replace($filter,’’,$string) ß this is useless in this situation I
tried and it does not change the string at all.

Understand the newlines and returns do not display in the string as
literals. Meaning you do not see /n or /r it is hidden.

Try this:

$strippedStr= preg_replace("%(\n|\r)%", "#", $string);

The "#" will let your see what's happening. Change it to simply "". for
final version.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PERFECT !!!! Thank you so much for that

I don't know why so many go to awful extremes to avoid using the preg functions. Rarely, does their overhead have a measurable affect on overall execution times.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to