Jeff Porter
New member
Please excuse my ignorance. I have very limited knowledge of PHP. But can someone please help. I am trying to output a postal address as a single line/paragraph like this:
address1, address2, town, county, postcode
Now address1 and address2 may NOT be included, so what I have come up with is this:
<?php
$address_1 = the_field('address_1');
if (!empty($address_1)) {
echo $address_1, ",";
} else {
echo "";
}
?>
The result I am getting is:
address1 address2 town, county, postcode // NOTE minus the commas for address1 and address2
Any help appreciated.
address1, address2, town, county, postcode
Now address1 and address2 may NOT be included, so what I have come up with is this:
<?php
$address_1 = the_field('address_1');
if (!empty($address_1)) {
echo $address_1, ",";
} else {
echo "";
}
?>
The result I am getting is:
address1 address2 town, county, postcode // NOTE minus the commas for address1 and address2
Any help appreciated.