Jump to content

Checkboxes and arrays


Wolphie

Recommended Posts

Ok so,

  If have a group of checkboxes, and I know how to get the values from each of them in an array. However, I can't seem to find a solution to

only return a default value if "none" of the checkboxes are checked, and only return the values that are checked.

 

I've tried:

  foreach($form_values['completed'] as $complete) {
    if($complete != 0) {
      $completed = array();
      $completed = array_push($completed, $complete);
    }
  }
  
  if (is_array($completed)) {
    $completed = implode(', ', $completed);
  }
  else {
    $completed = 'None';
  }

Link to comment
https://forums.phpfreaks.com/topic/118769-checkboxes-and-arrays/
Share on other sites

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.