title: Build new custom Array from Wordpress $wpdb->get_results array
body: <p>I'm currently taking the results of a table and using wp_send_json to using it as a JSON response.  The data is encoded as expected, however I'd like to tweak the output a bit by changing the keys, formating, and order.  I'm not sure how to rebuild the array and encode as json after so I'm looking for a little bit of help. </p>
  
  <pre><code>$stuff= $wpdb-&gt;get_results( $wpdb-&gt;prepare("SELECT * FROM wp_table"), ARRAY_A);
  wp_send_json($stuff);
  </code></pre>
  
  <p>As of now the results I get via print_r look as follows.  </p>
  
  <pre><code>Array(
      [0] =&gt; Array(
          [id] =&gt; 1[gender] =&gt; Male[email] =&gt; test@loas . com[lat] =&gt; 38[long] =&gt; - 97[country_srt] =&gt; USA[country_long] =&gt; UnitedStates
      ) [1] =&gt; Array(
          [id] =&gt; 2[gender] =&gt; Female[email] =&gt; femal@test . com[lat] =&gt; 38[long] =&gt; - 97[country_srt] =&gt; USA[country_long] =&gt; UnitedStates
      )
  )
  </code></pre>
  
  <p>When encoded I get:</p>
  
  <pre><code>[{
      "id": "1",
      "gender": "Male",
      "email": "test@loas.com",
      "lat": "45",
      "long": "-76",
      "country_srt": "USA",
      "country_long": "United States"
  }, {
      "id": "2",
      "gender": "Female",
      "email": "femal@test.com",
      "lat": "98",
      "long": "-34",
      "country_srt": "USA",
      "country_long": "United States"
  }]
  </code></pre>
  
  <p>Thing is, I don't really need some of these values and also need to format some things to output for easy map plotting.  For instance the country longform and gender go into an html formatted string.  What I'm looking to do is transform this array to result in:</p>
  
  <pre><code>[ idhere: {
      "value": "1",
      "latitude": "45",
      "longitude": "-76",
      "tooltip": {"content":"HTML Showing gender variable and country variable"}
  }, idhere: {
      "value": "2",
      "latitude": "98",
      "longitude": "-34",
      "tooltip": {"content":"HTML Showing gender variable and country variable"}
  }]
  </code></pre>