title: How to pass an array of events to the FullCalendar jQuery plugin
body: <p>I am using the FullCalendar jquery plugin to display a calendar on my page.  I am now trying to figure out how to populate the calendar with my own events.  I have some code which loops through my query results and builds a <code>$json_array</code> of all the events.  This seems to be working because when I output the array to the screen I can see my events and they look properly formatted, like this:</p>
  
  <pre><code>    [eventData] =&gt; Array
      (
          [0] =&gt; Array
              (
                  [title] =&gt; 09:30 AM Hearing-950 Boundary Rd, South Glengarry PC540 H#559588-Council Chambers - 6 Oak St, Lancaster
                  [start] =&gt; 2014-04-29
              )
  
          [1] =&gt; Array
              (
                  [title] =&gt; 09:30 AM Hearing-6-12 Park St, Brockville PC340 H#559597-Council Chambers - 1 King St W., Brockville
                  [start] =&gt; 2014-04-30
              )
  
          [2] =&gt; Array
              (
                  [title] =&gt; 09:30 AM Hearing-1340 Kingston Rd, Pickering PC430 H#558975-Council Chambers, One The Esplanade, Pickering
                  [start] =&gt; 2014-04-01
              )
       )
  </code></pre>
  
  <p>In addition to building the <code>$json_array</code>, my sample code also builds a string called <code>$eventString</code> which also looks like it could be used as the event source for the calendar.  Here is the code which builds both the <code>$json_array</code> and <code>$eventString</code>:</p>
  
  <pre><code>&lt;?php 
  $qryEvents = $this-&gt;db-&gt;query(" SELECT date(tbldeadlines.Date) AS D, 
      time_format(tbldeadlines.HearingStartTime, '%H:%i %p') AS S, 
      tbldeadlines.Type AS T, 
      tbldeadlines.`Property#` AS P, 
      tblproperties.`Property Address` AS A, 
      tblmunicipalities.MunicipalityName AS M,
      tblproperties.`Property Owner` AS O, 
      tbldeadlines.HearingNotes AS N, 
      tbldeadlines.HearingNumber AS H, 
      format(tblproperties.PC,0) AS PC, 
      tblpropertycodes.`SIMPLE PC NAME` AS PCN
  FROM tbldeadlines INNER JOIN tblproperties ON tbldeadlines.`Property#` = tblproperties.`Property#`
       INNER JOIN tblmunicipalities ON tblproperties.County = tblmunicipalities.MunicipalitiesCounty
       INNER JOIN tblpropertycodes ON tblproperties.PC = tblpropertycodes.PC
  WHERE 1 {$whereCond} 
  GROUP BY P, D, T, A, N, H, S");
  
  $evntArray =  $qryEvents-&gt;result_array();
  $eventString = "";
  if(!empty($evntArray)){
      $json_array = array();
      $eventString .= "[" ;
      foreach($evntArray as $row){
          $json_array[] = array("title"=&gt;addslashes($row['S'])." ".addslashes($row['T'])."-".addslashes($row['A']).", ".addslashes($row['M'])." PC".addslashes($row['PC'])." H#".addslashes($row['H'])."-".addslashes($row['N']), "start"=&gt; date('Y-m-d',strtotime($row['D'])));
          $eventString .= "{title:'".addslashes($row['N'])."',start:'".date('Y-m-d',strtotime($row['D']))."'},";
      }
      $eventString .= substr($eventString,0,-1);
      $eventString .= "]";
  } 
  
  if($_GET['start'] != "" &amp;&amp; $_GET['end'] != ""){
      echo json_encode($json_array); 
  }       
  
  $data['eventData'] = $json_array; 
  $data['calurl'] = 'http://mysite.ca/admin/view';    
  $this-&gt;load-&gt;view('pts_template', $data);    
  ?&gt;
  </code></pre>
  
  <p>My problem is that I don't know how to get my results into the calendar. How can I initialize the calendar and reference the array that is already on the page?  Which should I be using, the <code>$json_array</code> or the <code>$eventString</code>?</p>
  
  <p>Thanks for any ideas you might have.</p>