Sorry if this is really basic but I am just learning PHP.
I have some code that looks like:
<h4><?=$prop['house_number']?>, <?=$prop['street']?>, <?=$prop['town']?></h4>
That is bring back from the database eg: 55, main street, townname
When the address does not contain a street name it comes back as eg: 55, , townname.
I want to know how to remove the commer so it just brings back eg: 55, townname.
Hopefully it is a really easy one but I have tried a couple of things and cannot seem to get it right.
Many thanks
You could use ternary operators to check if each var is empty. Have a look at http://davidwalsh.name/php-shorthand-if-else-ternary-operators
The code would then look like :