Looping through an array and turn strings into nested array
<p>I have 10 arrays with the following format:</p>

<p>This is $data</p>

<pre><code>Array
(
    [0] =&gt; stdClass Object
        (
                [id] =&gt; 1
                [name] =&gt; Product Name
                [category] =&gt; Product category
                [permName] =&gt; Product-Name
                [picture] =&gt; http://randomdomain.com/1.jpg
                [idUser] =&gt; 1,2,3
                [rating] =&gt; 120,880,450
                [description] =&gt; Review 1, Review 2, Review 3
                [firstName] =&gt; Name 1, Name 2, Name 3
                [lastName] =&gt; Last 1, Last 2, Last 3
                [userName] =&gt; userName 1, Username 2, Username 3
        )
    [1] =&gt; stdClass Object
        (
                [id] =&gt; 2
                [name] =&gt; Product Name 2
                [category] =&gt; Product category
                [permName] =&gt; Product-Name
                [picture] =&gt; http://randomdomain.com/1.jpg
                [idUser] =&gt; 1,2,3
                [rating] =&gt; 120,880,450
                [description] =&gt; Review 1, Review 2, Review 3
                [firstName] =&gt; Name 1, Name 2, Name 3
                [lastName] =&gt; Last 1, Last 2, Last 3
                [userName] =&gt; userName 1, Username 2, Username 3
        )  

)
</code></pre>

<p>I wanna turn each arrays idUser, rating, description, firstName, lastName, userName in a nested array. I was thinking of doing something like this:</p>

<pre><code>foreach ($data as $row) {                   
    $firstName = $row-&gt;firstName;           
    $firstNames = explode(',', $firstName); 
}
</code></pre>

<p>Which turns it into array but how would I then insert it back into the original array in its original spot but as a nested array?</p>
