title: Convert array to JSON
body: <p>I have an array:</p>
  
  <pre><code>["dyGYrcK", "tRCCMsK" ,"CM1HGi3"] 
  </code></pre>
  
  <p>I want to convert it to json like this:</p>
  
  <pre><code>{
      data: [
        {
          "expiry" : 0,
          "tokens" : {
              "0" : "dyGYrcK",
              "1" : "tRCCMsK",
              "2" : "CM1HGi3"
          }
        }
      ]
  }
  </code></pre>
  
  <p>I am finding this to be very difficult. I have tried alot and I am getting this output currently:</p>
  
  <pre><code>{
    "data": [
      "dyGYrcK",
      "tRCCMsK",
      "CM1HGi3"
    ]
  }
  </code></pre>
  
  <p>I am currently doing this:</p>
  
  <pre><code>return response()-&gt;json(['data' =&gt; $data], 201); //$data is array
  </code></pre>