Hi, I have a series of checkboxes that may or may not be checked.

This means that when none of them are checked, the implode function has nothing to implode so returns an error...I think that's why I get the error.

The form is processed and I was wandering if anyone could help with the following...

$retval = ..., implode(",",$_POST['optional']), ...

I think I have the formatting correct, but I need to do some sort of check that will only activate the implode if some of the checkboxes have been checked - if none are checked, then don't implode.

I have looked on google for this, but can't find an example that seems to work or fits in to the script.


10 Years
Discussion Span
Last Post by skinbug

right, sorted it myself...bit cumbersum perhaps, but it works for me...

if(isset($_POST['optional'])) {
   $retval = ..., implode(",",$_POST['optional'], ...
else {
   $retval = ..., $_POST['optional'], ...

Basically, when no checkboxes are checked, there is no array created, hence nothing to implode ergo error...just incase anyone wanted to know!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.