title: Hard time with php associative array, numbers won't print?
body: <p>I am embarrass to ask this because it's seems so easy . forgive me.</p>
  
  <p>the following php :</p>
  
  <pre><code>&lt;?php
  $cars=array("Volvo","BMW","Toyota");
  $arrlength=count($cars);
  
  $data = array();
  for($x=0;$x&lt;$arrlength;$x++)
    {
      $data[(string)$x]=$cars[$x];
    }
    var_dump($data);
    echo json_encode($data);
  ?&gt;
  </code></pre>
  
  <p>give me this:</p>
  
  <pre><code>array(3) {
    [0]=&gt;
    string(5) "Volvo"
    [1]=&gt;
    string(3) "BMW"
    [2]=&gt;
    string(6) "Toyota"
  }
  ["Volvo","BMW","Toyota"]
  </code></pre>
  
  <p>The dump looks great but when I encode it , it disappear,</p>
  
  <p>But when I do <code>$data[$cars[$x]] = $x;</code> I get the opposite of what I want</p>
  
  <pre><code>array(3) {
    ["Volvo"]=&gt;
    int(0)
    ["BMW"]=&gt;
    int(1)
    ["Toyota"]=&gt;
    int(2)
  }
  {"Volvo":0,"BMW":1,"Toyota":2}
  </code></pre>
  
  <p>But the number shows in the JSON what I really want is this:</p>
  
  <pre><code>{0:"Volvo", 1:"BMW", 2:"Toyota"}
  </code></pre>