Jump to content

adding seperator if values are NOT empty


wkilc

Recommended Posts

Hi all,

 

I'm pretty much a noob, and I've tried looking in the manual, but I don't know enough to even look in the right direction.  Implode function perhaps?

 

I'm pulling values from a MySQL database...

 

for example:

$food $drink $price

 

If the array has a value in it , I want it to report the value and then add a separator (like a comma) between the values.  If the array is empty, I don't want the orphaned comma.

 

For example:

$food = ""
$drink = "beer"
$price = "five dollars"

 

Right I can print:

beer five dollars

 

even:

, beer, five dollars

 

But what I want is:

beer, five dollars

 

Thanks.

 

~Wayne

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.