Sudi Sudi - 10 days ago 5
MySQL Question

PHP: How to add an extra field and value in this array

I have an array which stores the values to specific fields. What i want to do here is to add an extra field name and value into this array. How can i do it?

array_walk($files_data, 'array_sanitize');

$fields = '`'.implode('` , `', array_keys($files_data)).'`';
$data = '\''.implode('\', \'',$files_data).'\'';

mysqli_query($dbCon,"INSERT INTO users_info($fields) VALUES ($data) ");

Answer
$files_data['yourFieldName'] = $yourValue;
array_walk($files_data, 'array_sanitize');

        $fields = '`'.implode('` , `', array_keys($files_data)).'`';
        $data = '\''.implode('\', \'',$files_data).'\'';

   mysqli_query($dbCon,"INSERT INTO users_info($fields) VALUES ($data) ");