title: how to convert multidimensional array to object in php?
body: <p>i have a multidimensional array:</p>
  
  <pre><code>$image_path = array('sm'=&gt;$sm,'lg'=&gt;$lg,'secondary'=&gt;$sec_image);
  </code></pre>
  
  <p>witch looks like this:</p>
  
  <pre><code>[_media_path:protected] =&gt; Array
              (
                  [main_thumb] =&gt; http://example.com/e4150.jpg
                  [main_large] =&gt; http://example.com/e4150.jpg
                  [secondary] =&gt; Array
                      (
                          [0] =&gt; http://example.com/e4150.jpg
                          [1] =&gt; http://example.com/e4150.jpg
                          [2] =&gt; http://example.com/e9243.jpg
                          [3] =&gt; http://example.com/e9244.jpg
                      )
  
              )
  </code></pre>
  
  <p>and i would like to convert it into an object and retain the key names.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>
  
  <p>edit: <code>$obj = (object)$image_path;</code> doesn't seem to work. i need a different way of looping through the array and creating a object</p>