Member Avatar for skinbug

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.

cheers.

Member Avatar for 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!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.