Q: Javascript Object To Array Convertion For Sending To Php I have a javascript dynimic array creator code as below
function createArray() {

    var myArr = new Object();
    myArr[0] = createSubArray('apple');
    myArr[1] = createSubArray('Mango');
    myArr[2] = createSubArray('Pineapple');
    myArr[3] = createSubArray('Grape');
    document.getElementById("a").innerHTML = JSON.stringify(myArr);
    return myArr;

}


function createSubArray(name){
    var arr = new Object();
    elems = document.getElementsByName(name);
    for (var i=0;i<elems.length;i++){
        if (elems[i].checked){
            arr[name] =  elems[i].value;
            arr['price'] =  elems[i].getAttribute('data-price');
        }
    }
    return arr;
   }

In this code i need to send the value as an array not an object.
I have tried changing the new Object(); to new Array(); in  createArray function but when i json_decode i get the result as below 
array
  0 => 
    object(stdClass)[1]
      public 'apple' => string 'light' (length=5)
      public 'price' => string '10' (length=2)
  1 => 
    object(stdClass)[2]
      public 'Mango' => string 'light' (length=5)
      public 'price' => string '30' (length=2)
  2 => 
    object(stdClass)[3]
      public 'Pineapple' => string 'light' (length=5)
      public 'price' => string '50' (length=2)
  3 => 
    object(stdClass)[4]
      public 'Grape' => string 'dark' (length=4)
      public 'price' => string '80' (length=2)

if i change new Object in createSubArray function i din't get any values..
Kindly check below
new Object changed to new Array in createArray function 
new Object changed to new Array in createArray And createSubArray function 
How i can change the object into an array ?
Kindly help me in solving this 

A: $array = json_decode($json, true);

Setting the second parameter to true forces json_decode to return an associative array instead of a stdClass.
