json_encode format in codeigniter
<p>With my present code I get the right details from my dbase with json_encode.</p>

<pre><code> [{
    "tour_id": "1",
    "tour_name": "Test this",
    "start": "2016-01-12 13:21:32",
    "end": "2016-01-15 13:21:35",
    "itinerary_photo": "Desert.jpg"
 }][{
    "tour_id": "3",
    "tour_name": "Everest",
    "start": "2016-02-10 13:23:00",
    "end": "2016-02-18 13:23:07",
    "itinerary_photo": "Chrysanthemum.jpg"
}]
</code></pre>

<p><strong>EXPECTED JSON FEED</strong> <br>
I am using a json feed in order to add an event to fullcalendar. And the format of my json_encode results should be like this: </p>

<pre><code>[{
    "tour_id": "1",
    "tour_name": "Test this",
    "start": "2016-01-12 13:21:32",
    "end": "2016-01-15 13:21:35",
    "itinerary_photo": "Desert.jpg"
}, {
    "tour_id": "3",
    "tour_name": "Everest",
    "start": "2016-02-10 13:23:00",
    "end": "2016-02-18 13:23:07",
    "itinerary_photo": "Chrysanthemum.jpg"
}]
</code></pre>

<p>the difference being the objects are stored into one array only. With the output im getting, it displays multiple arrays. </p>

<p>here is my code for the controller: </p>

<pre><code>public function getBookedCal(){
    if ($this-&gt;session-&gt;userdata('login')==true){
        $data['twimembers'] = $this-&gt;session-&gt;userdata('twimembers');
        $data['tour'] = $this-&gt;Model_MyBookedTours-&gt;getPaidTours($data['twimembers']['user_id']);
        foreach ($data['tour'] as $tourConfirm){
            $tourConfirm = $this-&gt;Model_MyBookedTours-&gt;getTourInfo($tourConfirm['Tour_packages_tourpkg_id']);
            echo json_encode($tourConfirm);
        }   
        //echo json_encode($tourConfirm); //this outputs only a single array
    }//end if
}//end function
</code></pre>

<p>MODEL:</p>

<pre><code>function getPaidTours($user_id){
    $this-&gt;db-&gt;where('User_accounts_user_id',$user_id);
    $this-&gt;db-&gt;where('payment_status','1'); //confirmed
    $query = $this-&gt;db-&gt;get('user_tourpkg');
    return $query-&gt;result_array();
} //calendar

function getTourInfo($tour_id){
    $this-&gt;db-&gt;select('tour_id,tour_name, start, end, itinerary_photo');
    $this-&gt;db-&gt;where('tour_id',$tour_id);
    $query = $this-&gt;db-&gt;get('tour_packages');
    return $query-&gt;result();
}
</code></pre>

<p><strong>is there any way i could obtain my expected json feed with some tweaks to my code?</strong></p>