title: How to create nested object from nested arrays in php
body: <p>I have code like this, that initialize config</p>
  
  <pre class="lang-php prettyprint-override"><code>    $this-&gt;config = array(
          'users' =&gt; array(
              array('name' =&gt; 'admin',
                    'password' =&gt; $password
              )
          ),
          'tokens' =&gt; array(),
          'sessions' =&gt; array(),
      );
  </code></pre>
  
  <p>that I'm saving to a file using <code>json_encode($this-&gt;config)</code> and later I load it using </p>
  
  <pre class="lang-php prettyprint-override"><code>json_decode(file_get_contents('file.json'));
  </code></pre>
  
  <p>it create nested objects, I would like to have this nested object when I initialize and the config, <strong>is there a way to create this nested object other then this?</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>$this-&gt;config = json_decode(json_encode($this-&gt;config));
  </code></pre>