js
var sim_list=[];
var simvalue = $('input[name="simnamecbx"]:checked').each(function(){
var sim_name=this.value.split(" ")[0];
console.log("simname:",sim_name);
sim_list.push({
sim_name
});
);
console.log(sim_list);
var simulation_list = JSON.stringify(sim_list);
$.ajax({ url: 'addprogram.php',
data: {addpgmname:addprogname, addpgmcomp:addprogcomp, addpgmdate:addprogdate, simselvalue:simulation_list},
type: 'post',
dataType: 'json',
success: function(output){
var a = output;
console.log(a);
}
});
php
$simvalue = json_decode($_POST["simselvalue"],true);
foreach($simvalue as $key => $value) {
print_r($value);
}
Question
When I execute the above php I get the values as
Array
(
[0] => Array
(
[sim_name] => 12
)
[1] => Array
(
[sim_name] => 13
)
[2] => Array
(
[sim_name] => 14
)
)
But I want the result to be like 12, 13, 14 which can be inserted into mysql table. Please explain how to parse this array that I get from javascript.