Jump to content

list separate by comma


This topic is 6125 days old. Please don't post here. Open a new topic instead.

Recommended Posts

In have a database with checkboxes, but when display at the webpage it shows me as a list, so I am wonder how can I display them separated by comma.

Here is what I have:

<?php echo $recordData['color'][0]; ?>

it does display as

red

blue

white

But I would like it to be showing as:

red, blue, white

Any help will be appreciated.

Link to comment
Share on other sites

You can use the str_replace() function (http://www.php.net/manual/en/function.str-replace.php)

so you could do something like:

echo (str_replace($recordData['color'][0] , ", " , "r"));

or

$out = str_replace($recordData['color'][0] , ", " , "r");

echo ($out);

The r is a return. I'm not sure what the line break character is in your case, it may be n.

Regards, Don

Link to comment
Share on other sites

This topic is 6125 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.