title: How to better format the JSON string generator with PHP json_encode()?
body: <p>I'm saving data inside arrays with php's <code>json_encode()</code> function and then encoding them into json strings in order to save them into a single database field.</p>
  
  <p><strong>This is what I've been doing:</strong></p>
  
  <pre><code>$fechaMensaje = $_POST['fechaMensaje'];
  $mensaje = $_POST['mensaje'];
  $estadoMensaje = 'abierto';
  $data['fecha'][] = $fechaMensaje;
  $data['autor'][] = $userEmail;
  $data['mensaje'][] = $mensaje;
  $datosMensaje = json_encode($data);
  </code></pre>
  
  <p><strong>This does work, and it does creates a string like this:</strong></p>
  
  <pre><code>{
  "fecha":["29-09-2016 11:12:51 AM"],
  "autor":["demo@example.com"],
  "mensaje":["lorem ipsum"]
  }
  </code></pre>
  
  <p><strong>This is the array I've got when decoding the string:</strong></p>
  
  <pre><code>{
      ["fecha"]=&gt; array(1) { 
          [0]=&gt; string(22) "29-09-2016 11:12:51 AM" 
      } 
      ["autor"]=&gt; array(1) { 
          [0]=&gt; string(23) "demo@example.com" 
      } 
      ["mensaje"]=&gt; array(1) { 
          [0]=&gt; string(11) "lorem ipsum" 
      } 
  }   
  </code></pre>
  
  <p>Now, my question is, how may I change the way I'm generating the array in the first place, to get this output instead? (having the three items in the same array, so when I do add more elements it's going to be more organized).</p>
  
  <pre><code>{
      ["0"]=&gt; array(3) { 
          ['fecha']=&gt; string(22) "29-09-2016 11:12:51 AM" 
          ['autor']=&gt; string(23) "demo@example.com" 
          ['mensaje']=&gt; string(11) "lorem ipsum" 
      } 
      [1]=&gt; array(3) { 
          ...
          ...
          ...       
      } 
  }   
  </code></pre>