View Full Version : Removing line break from string?

04-01-2004, 04:56 PM
I'm using PayPal IPN to post the variables back to DB, and the address_street post variable has a line break in it. I can not see it, but it's there. PayPal says theres a %0D%0A between the 2 addresses in this field.
For example 123 any street%0D%0AApartment 5
To me it views as...
123 any street
Apartment 5

Does anyone know the PHP command to remove this line break and at the same time split the 2 addresses into 2 fields like address1 and address2. Thanks in advance.

04-02-2004, 06:28 AM
$arr = explode( "\n", $instr );
$address1 = $arr[0];
$address2 = $arr[1];


04-02-2004, 06:43 AM
That did split the address, but the line break is still in there? Do you know if maybe "\n" is equivilent to either "%0D" or "%0A" and it was able to strip one of them out and not the other?

I just tried "\r\n" and that worked. Thanks for the help Jalal. :D

One more question if you don't mind...
Is there a PHP command that will strip out HTML from a string? My merchant account passes one variable that is an HTML table and it's about 1000 characters long, but I would rather just store the info (about 30 characters) and not all the HTML table stuff. Didn't know if there is a command that is set up to do automatically parse HTML, or if I'm going to have to parse the results like any other string.

04-02-2004, 07:02 AM
Use strip_tags() (http://www.php.net/manual/en/function.strip-tags.php).

04-06-2004, 08:06 PM
strip_tags() is the way to go to remove both HTML code and line breaks, tabs, etc. I have found it very useful.