title: How to merge two object of an array into one?
body: <p>I want to modify json file.In this question i have submitted required information.
  Here the controller part..</p>
  <pre><code>    $questionLimit=$questions-&gt;count();
      $response=[];
      for($i=0;$i&lt;$questionLimit;$i++){
         $response[$i]=[
          'question_with_choice'=&gt;$questions[$i],
          'candidate_chosen_ans'=&gt;$quizSessionAns[$i]
         ];
      }
      return response($response);
  </code></pre>
  <p>The output of the above code is given below..</p>
  <pre><code>[
  {
      &quot;question_with_choice&quot;: {
          &quot;id&quot;: 1,
          &quot;name&quot;: &quot;which is the prime number?&quot;,
          &quot;image&quot;: null,
          &quot;config&quot;: &quot;1&quot;,
          &quot;question_type&quot;: &quot;Multiple Quesiton&quot;,
          &quot;choices&quot;: []
      },
      *&quot;candidate_chosen_ans&quot;: 2*
  }    
  ]
  </code></pre>
  <p>But my expected output will be like...</p>
  <pre><code> {
      &quot;question_with_choice&quot;: {
          &quot;id&quot;: 1,
          &quot;name&quot;: &quot;which is the prime number?&quot;,
          &quot;image&quot;: null,
          &quot;config&quot;: &quot;1&quot;,
          &quot;choices&quot;: []
          &quot;candidate_chosen_ans&quot;: 2
      },
  }
  ]
  </code></pre>