Search code examples
phpmysqlimailto

Converting \r\n in a mailto link


I've tried every combination and read every post I can find but I still cannot make this work.

I have comments that are kept in a MySQL DB. I create a simple mailto link but if the user has entered carriage returns into the textarea it displays like this:

Comments: Good\r\nMore good

I'm trying to convert the \r\n to %0D%0A but I've been totally incapable of getting it to replace these special characters.


Solution

  • Managed to resolve it with the use of single not double quotes:

    $edit = str_replace('\r\n', '%0D%0A', $edit);