title: Write an array to config in Codeigniter?
body: <p>I'm working with a config file that I have create in order to store users. This surely wasn't what the configs were intended to be used for, but it's an extremely small application and I think that it would be a nice solution.</p>
  
  <p>My array looks like this:</p>
  
  <pre><code>$config['users'] = array(array('username' =&gt; 'username', 'password' =&gt; 'password'));
  </code></pre>
  
  <p>This works well. I can retrieve the information quick and easy. BUT, if I try to write a new array (a new user) to the config file I get this error:
  Illegal offset type in isset or empty</p>
  
  <p>I'm using <code>$this-&gt;config-&gt;item('users', array('username' =&gt;....))</code> which doesn't appear to support arrays.</p>
  
  <p>How can I write arrays to my config variable? Is there another way?</p>
  
  <p>EDIT: Alright, the error is fixed thanks to the answer given by phirschy. I was so sure in my head that I could use config->item() that I didn't check the manual for a config->set_item()... BUT, it still doesn't work. Here is the specific code:</p>
  
  <pre><code>        $users = $this-&gt;config-&gt;item('users');
          array_push($users, array('username' =&gt; $this-&gt;input-&gt;post('username'), 'password' =&gt; $this-&gt;input-&gt;post('password')));
          $this-&gt;config-&gt;set_item('users', json_encode($users));
          echo json_encode($users);
  </code></pre>
  
  <p>This code is called via Ajax, and I have an alert box to see if it the values are correct. They are. And as you can see, I've tried storing it as json instead of array as well.... but that doesn't work either. Help please?</p>
  
  <p>thank you</p>