title: Json array monthly data php laravel
body: <p>I fetched data from database monthly based counts users. I got data in this format.
  Array
  (
  [0] =&gt; stdClass Object
  (
  [counts] =&gt; 1
  [monthname] =&gt; April
  )</p>
  <pre><code>[1] =&gt; stdClass Object
      (
          [counts] =&gt; 1
          [monthname] =&gt; February
      )
  
  [2] =&gt; stdClass Object
      (
          [counts] =&gt; 1
          [monthname] =&gt; January
      )
  
  [3] =&gt; stdClass Object
      (
          [counts] =&gt; 2
          [monthname] =&gt; July
      )
  
  [4] =&gt; stdClass Object
      (
          [counts] =&gt; 1
          [monthname] =&gt; June
      )
  
  [5] =&gt; stdClass Object
      (
          [counts] =&gt; 1
          [monthname] =&gt; March
      )
  
  [6] =&gt; stdClass Object
      (
          [counts] =&gt; 1
          [monthname] =&gt; May
      )
  </code></pre>
  <p>)</p>
  <p>But I need this in this format</p>
  <p>Array
  (
  [February] =&gt; stdClass Object
  (
  [counts] =&gt; 1
  )</p>
  <p>[January] =&gt; stdClass Object
  (
  [counts] =&gt; 1
  )</p>
  <p>[July] =&gt; stdClass Object
  (
  [counts] =&gt; 2
  )</p>
  <p>[June] =&gt; stdClass Object
  (
  [counts] =&gt; 1
  )</p>
  <p>)
  .
  .
  .
  . and so on</p>
  <p>Thanks in advance</p>