Insert a multi-line address
Hello, All -
I'm trying to find a smart way to insert a multi-line address into a CMSB table. I'm using the standard $colsToValues approach which I've used many times - but it's all coming appart when it comes to the address.
I am trying to create a multi-line entry formed from several variables:
This works fine:
$colsToValues['address'] = $_SESSION['strAddress1']."\r\n".$_SESSION['strAddress2']."\r\n".$_SESSION['strCity'];
However, in practise, hardly anyone ever fills in Address2. This means that when the address appears in the DB it looks like this:
I want to get rid of the gap!
I've tried using a ternary operator - to exclude the line break when Address2 is not present - but it doesn't quite work as expected.
$colsToValues['address'] = $_SESSION['strAddress1']."\r\n".$_SESSION['strAddress2'].$_SESSION['strAddress2'] ? "\r\n" : ''.$_SESSION['strCity'];
Can someone please explain what I'm doing wrong?!