convert an array to json in laravel controller
<p>Hy Guys, I have a problem again. and this time with my laravel project.</p>

<p>I have a controller function like this:</p>

<pre><code>public function postDetail(Request $request)
{
  $product_requests = $request-&gt;sku;
  $arr = [];
}
</code></pre>

<p>And my <code>$request-&gt;sku</code> looked like this:</p>

<pre><code>[612552892 =&gt; ['quantity' =&gt; '1'], 625512336 =&gt; ['quantity' =&gt; '10']]
</code></pre>

<p>but i need the json file like this:</p>

<pre><code>[{"sku_id": 612552892, "quantity": "1"}, {"sku_id": 625512336, "quantity": "10"}]
</code></pre>

<p>so, should i make the key too? but.. How ?</p>

<p>and I think I have to make it in foreach loop right? anyone can help me?</p>