title: Converting array to an object with an array inside it
body: <p>I have an array with three keys and values. I need to convert first two keys into an object and the 3rd must remain an array but with and object inside it.</p>
  
  <p><strong>My Array:</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>$person = array(
      'name' =&gt; 'bob',
      'surname' =&gt; 'white',
      'address' =&gt; array(
          'street' =&gt; 'green road',
          'houseNo' =&gt; '89',
          'city' =&gt; 'Liverpool'
      )
  );
  </code></pre>
  
  <p>I want to convert this array into an object like so:</p>
  
  <pre class="lang-php prettyprint-override"><code>$personInformation = json_decode(json_encode($person));
  </code></pre>
  
  <p><strong>Which gives me this:</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>object(stdClass)(3)
  {
      'name' =&gt; 'bob',
      'surname' =&gt; 'white',
      'address' =&gt; object(stdClass)(3) 
      { 
           'street' =&gt; 'green road',         
           'houseNo' =&gt; '89',
           'city' =&gt; 'Liverpool'
      }
  }
  </code></pre>
  
  <p><strong>But what I am after is this:</strong> </p>
  
  <pre class="lang-php prettyprint-override"><code>object(stdClass)(3)
  {
      'name' =&gt; 'bob',
      'surname' =&gt; 'white',
      'address' =&gt; array(
         object(stdClass)(3) 
         { 
           'street' =&gt; 'green road',         
           'houseNo' =&gt; '89',
           'city' =&gt; 'Liverpool'
         }
     )
  }
  </code></pre>
  
  <p>I'm really stuck on how to get this middle part sorted. </p>