title: JSON Key Value Pairs within an Array in PHP using the json_encode() Function
body: <p>I am trying to get my JSON output in a particular syntax</p>
  
  <p>here is my code:</p>
  
  <pre><code>$ss = array('1.jpg', '2.jpg');
  $dates = array('eu' =&gt; '59.99', 'us' =&gt; '39.99');
  $array1 = array('name' =&gt; 'game1', 'publisher' =&gt; 'ubisoft', 'screenshots' =&gt; $ss, 'dates' =&gt; $dates, 'added' =&gt; '2014/12/31');
  
  echo json_encode($array1);
  </code></pre>
  
  <p>it gives me this output:</p>
  
  <pre><code>{
  name: "game1",
  publisher: "ubisoft",
  screenshots: [
  "1.jpg",
  "2.jpg"
  ],
  dates: {
  eu: "59.99",
  us: "39.99"
  },
  ],
  added: "2014/12/31"
  }
  </code></pre>
  
  <p>which is CLOSE but, not exactly what I need. The dates need to be formatted slightly different. Like this:</p>
  
  <pre><code>{
  name: "game1",
  publisher: "ubisoft",
  screenshots: [
  "1.jpg",
  "2.jpg"
  ],
  dates: [
  {
  eu: "59.99"
  },
  {
  us: "39.99"
  }
  ],
  added: "2014/12/31"
  }
  </code></pre>
  
  <p>I have tried adding more dimensions to the $dates array, but that still doesn't give quite the right output. Unfortunately the php manual for the json_encode() function doesn't provide much help and there is very little documentation on more complex json encodes within php that i have found with google searching.</p>
  
  <p>Any help would be greatly appreciated.</p>