I have a string with line breaks from the return key in a text box from a form. I need to replace the line breaks with a double pipe. (||) I wasn't sure how to replace the line break, so I used nl2br to covert it to an html break and then attempted to replace the html break. So far, I'm using this code.
$thestring = nl2br($deliveryaddress);
$pattern = '<br />';
$replacement = '||';
$cleanstring = preg_replace($pattern, $replacement, $thestring);
However, it replaces the <br /> with <||>.
What am I doing wrong and how do I fix it?