I'm not sure if this will work, or how to make it work.
Any help would be so great thanks.
I need to make this contitional statement string into one variabe?
How can I do this?
if ($address1) {
echo $address1 . ', ';
}
if ($address2) {
echo $address2 . ', ';
}
if ($address3) {
echo $address3 . ', ';
}
if ($address4) {
echo $address4 . ', ';
}
if ($townCity) {
echo $townCity . ', ';
}
if ($county) {
echo $county . ', ';
}
if ($postCode) {
echo $postCode;
}
So basically I need this in one variable, and the reason I have it in if statements, is because it is possible for the some off these variables to not exist.
And after each variable, it has a comma and space.
If I do it like this...
$singleVar = $address1 . ', ' .
$address2 . ', ' .
$address3 . ', ' .
$address4 . ', ' .
$townCity . ', ' .
$county . ', ' .
$postCode;
Then for the variables that do not exist, will have and extra comma and space - not cool.
Can any one please advise.
Thanks