<script>
$("#submit").click(function () {
   var newhour= [];
   for (var i = 0; i < arrayNumbers.length; i++) {
        newhour.push(arrayNumbers[i].toString().split(','));   
        console.log("each: " + newhour[i]); // output: each: 07:00,08:30
                                                       each: 18:00,19:00                                                   
   }
   console.log("all: " + newhour); //output: all: 07:00,08:30,18:00,19:00
   var jsonString = JSON.stringify(newhour);
   $.ajax({
         type: "POST",
         url: "exp.php",
         data:{data: jsonString}, 
         cache: false,
         success: function(){
                  alert("OK");
         }
   });
});
<script>
I want to pass the newhour array values to php and use them to insert into a table. so php file, exp.php:
$data = explode(",", $_POST['data']);
foreach($data as $d){
  echo $d;
  $sql = "insert into exp_table (hour) values ('$d')";
  mysql_query($sql);
}
However I can not take the values. What is wrong with the code? Could you please help me? Thanks in advance.
according to the answers i tried this on php side, but it returns NULL.
$data = json_decode($_POST['data'],true);
//$data = explode(",", $_POST['data']);
echo "data: " .$data;
var_dump($data); // no output
foreach($data as $d){
  echo $d; // no output
}
 
     
     
    