So I have the following snippet which I'm using to build a URL structure:
$map_url = 'https://google.com/maps/search/'.get_field('brand', $office).
' '.get_field('location', $office).
' '.get_field('address_line_1', $office).
', '.get_field('address_line_2', $office).
', '.get_field('city', $office).
', '.get_field('state', $office).
', '.get_field('zip_code', $office).
', '.get_field('country', $office);
When there are fields missing, I get the following outputs:
Edificio World Trade Center, Torre B, Avenida Francisco de Orellana, Guayaquil, , , Ecuador
Is there anyway to avoid appending the commas if a field is empty? Or is there a better way to structure my URL using all the ACF fields?