scosteve
-
Posts
2 -
Joined
-
Last visited
Posts posted by scosteve
-
-
I need to echo a string of variables and depending on the input one may be empty.
I have for example,
$row['add_1'] = 15 north st
$row['add_2'] = Apt 2
$row['city'] = Macon
$row['state'] = GA
echo $row['add_1'] . ", " . $row['add_2'] . ", " . $row['city'] . ", " . $row['state']
this will output
15 north st, Apt 2, Macon, GA.
My problem occurs when $row['add_2'] is empty.
the output looks like this.
15 north st, , Macon, GA
How do I get rid of the extra comma if the variable is empty?
How do I concatenate string with variable that is empty.
in PHP Coding Help
Posted
Thanks Rifts,
I used your method. I knew that method was possible but I was hoping to avoid all the extra code. I was looking for something that worked like the trim function in access. This works though.
Thanks