title: PHP JSON Array Objects adding 0 as key
body: <p>UPDATED QUESTION</p>
  
  <p>Here is my class...</p>
  
  <pre><code>class EbayItem
  {
      public $ebayItemId;
  }
  </code></pre>
  
  <p>Right before my foreach loop, I have the following:</p>
  
  <pre><code>$mainResponse = array();
  $mainResponse = [
      [
          "ack" =&gt; "success",
      ],
      "result" =&gt; []
      ];
  </code></pre>
  
  <p>Inside of my loop, I have...</p>
  
  <pre><code>$ebayItem = new EbayItem();
  $ebayItem-&gt;ebayItemId = $itemId;
  array_push($mainResponse['result'], $ebayItem);
  </code></pre>
  
  <p>Right after my loop I have...</p>
  
  <pre><code>echo json_encode($mainResponse);
  </code></pre>
  
  <p>This will produce the following:</p>
  
  <pre><code>{"0":{"ack":"success"},"result":[{"ebayItemId":{"0":"153532419741"}}]}
  </code></pre>
  
  <p>I need it to produce...</p>
  
  <pre><code>{"ack": "success","result": [{"ebayItemId": "153532419741","ebayItemTitle": "..."}]}
  </code></pre>