title: Form_validation errors into array
body: <p>I have a code for form validating in my CodeIgniter app:</p>
  
  <pre><code>$this-&gt;load-&gt;library('form_validation');
  
  $this-&gt;form_validation-&gt;set_rules('message', 'Message', 'trim|xss_clean|required');
  $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'trim|valid_email|required');
  
  if($this-&gt;form_validation-&gt;run() == FALSE)
  {
      // some errors
  }
  else
  {
      // do smth
      $response = array(
          'message' =&gt; "It works!"
      );
      echo json_encode($response);
  }
  </code></pre>
  
  <p>The form is AJAX-based, so frontend have to receive a JSON array with form errors, for example:</p>
  
  <pre><code>array (
    'email' =&gt; 'Bad email!',
    'password' =&gt; '6 symbols only!',
  )
  </code></pre>
  
  <p><strong>How to get such list or array with form validation errors in CodeIgniter?</strong></p>