I've built a survey site with Wordpress and CalderaWP forms and I'm running into an issue with the data storage for checkbox field values. My concern is that the data for these types of form submissions are being stored in the MySQL database as the string, "Array". Here is an example:
I have a number of things I'd like to do with this data, such as export it to a csv file, allow admins to change values via custom fields, etc. and in every front end form I've created the value shows up as the string, "Array". Here is a shot of one of the custom fields:
I've decided to write a wp cron that reformats this data into a front-end, usable format. The first part is getting the data and converting it. I've managed to use the $wpdb object to get all the fields that have the value "Array". It looks like this:
function reformat_mysql_arrays() {
global $wpdb;
$table_name = '`wp_mydatabase`.`wp_cf_form_entry_values`';
$results = $wpdb->get_results("SELECT *
FROM $table_name
WHERE `value` LIKE 'Array'
");
// Loop through the rows for the query
foreach($results as $key => $row) {
// Loop through the current row's columns
foreach($row as $column => $value) {
if($column == 'id') {
echo 'ID: ' . $value . ' | ';
}
if($column == 'value') {
var_dump($value);
}
}
}// END foreach column loop
}
reformat_mysql_arrays();
My concern is that when I var_dump()
the field value from the 'value' column, it appears to literally be the string, "Array", rather than an array I can parse. Here's a screen shot of the output of this function:
I've attempted every way I can think of to parse the values -- explode, implode, foreach, unserialize, array_values, etc. -- and I still cannot get any value out of the apparent array. Any help would be greatly appreciated. Am I missing something here?