title: json encoded php variable into javascript
body: <p>I'm retrieving data from MySql with php like this =></p>
  
  <pre><code>while ($birthday_row = $birthday_r-&gt;fetch_row()){
      $birthday_array[] = array(
      'title' =&gt; $birthday_row[0],
      'start' =&gt; $birthday_row[1] . "-" . $birthday_row[2]
      );
  }
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>var json_obj_birthday = &lt;?php if (isset($birthday_array)){echo json_encode($birthday_array);} ?&gt;;
  var json_obj_birthday_len = json_obj_birthday.length;
  var d = new Date();
  var event = [];
  for (var i=0;i&lt;json_obj_birthday_len;i++){ // adding manually year
      json_obj_birthday[i].start = d.getFullYear() + "-" + json_obj_birthday[i].start;
      event = {
          'title' : json_obj_birthday[i].title,
          'start' : json_obj_birthday[i].start
      };
  }
  </code></pre>
  
  <p>In above JavaScript code into <code>event</code> array is stored only for first data ,  it only stores for <code>json_obj_birthday[0]</code>, how can I store all information into <code>event</code> array ? thanks</p>
  
  <p>PS. I want that array <code>event</code> be json encoded with full information</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>now I've tried like this</p>
  
  <pre><code>var events = &lt;?php if (isset($birthday_array)){echo json_encode($birthday_array);} ?&gt;;
          var d = new Date();
          for (var i = 0; i &lt; events.length; i++){
              events[i].start = d.getFullYear() + "-" + events[i].start;
          }
  </code></pre>
  
  <p>and doesn't get desire result as well</p>
  
  <p><strong>Second Update</strong></p>
  
  <p>I need what I'm trying to do because want to pass this <code>event</code> variable into jQuery full calendar, here is script =></p>
  
  <pre><code>jQuery("#calendar").fullCalendar({ // initialize full calendar
          header: {
              left: 'prev,next today',
              center: 'title',
              right: 'month,basicWeek,basicDay'
          },
          events: [
              event
          ] // here was my fault , I must to have `events: event,`
      });
  </code></pre>
  
  <p>After tying your code guys , information into calendar doesn't inserted , That's what I mean doesn't work</p>
  
  <p>PS. If someone interested more deeply what I am doing and why , pls take a look at my previous question too <a href="https://stackoverflow.com/questions/12306351/add-birthday-events-into-jquery-full-calendar-each-year">add birthday events into jQuery full calendar each year</a></p>