title: Sorting JSON array from last to first by date in PHP, using a variable
body: <p>thanks for taking the time to look at my question. I'm working on something that's dynamic and has data added daily, but is sorted from first to last in the JSON file, when I want to go from last (most recent) to first.</p>
  <p>What I did was get the total number of entries by simply using</p>
  <pre><code>$total = $response['result']['total'];
  </code></pre>
  <p>Which gives me the total, 84. If I want the next last in the sequence, I just go:</p>
  <pre><code> echo $total - 1
  </code></pre>
  <p>Which gives me 83.</p>
  <p>This is where the problem comes in</p>
  <p>I'm arranging my data like this:</p>
  <pre><code>echo $reo[0]['previous_day_doses_administered'];
  </code></pre>
  <p>Where the [0] is, I want $total - 1</p>
  <p>However, I'm not sure how to get it, as it would be</p>
  <pre><code>   $reo[$response['result']['total']]['previous_day_doses_administered'];
  </code></pre>
  <p>which is definitely wrong. I'm wondering how to convert the $total to an integer, and have it no longer associated with the JSON array. I'm sorry if this is confusing! I just want to have the last 10 entries show up, instead of the first 10.</p>
  <p>So, that's basically it. I've tried a couple things I found on here, but it screwed everything up. The API updates daily. If you want the link, let me know.</p>
  <p>Thanks for taking the time to read this, and sorry that I'm being so confusing!</p>