php - Using checkboxes to specify items in array -


i want use checkboxes specify items added array, code follows:

$columns = array( if (isset($_post['customerid'])) {    'customer id' => 'customerid',  }   if (isset($_post['first_name'])) {      'first name' => 'first_name', } ); 

how can make work? many thanks

you can't use if statements inside of array, move outside so.

$columns = array();  if (isset($_post['customerid'])) {     $columns['customer id'] = 'customerid'; }  if (isset($_post['first_name'])) {     $columns['first name'] = 'first_name'; } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -