I'm sure this is very simple to do, but I'm really having a hard time with it and would appreciate a hand.
I have 4 variables that I'm retrieving from my db. They may have values or they may be null.
I'm trying to output the variables separated by a comma. My problem is that I want to suppress the comma if the variable is null.
If all four values were populated, I'd like it to look like this:
first, second, third, fourth
Or if only two of the four, like this:
first, fourth
(etc.)
Right now, I get:
first, , , fourth
because I'm using "echo $a, $b, $c, $d"
Can you help me figure out my comma formatting? I've tried a variety of "if" and "while" loops and just can't seem to get it.
Thanks ever so much!