Is there a way to assign an object property to an array?
<p>Pretty sure there is a way to do this but what I tried so far does not work</p>

<p>Consider we have an object $localDB with some properties, I was looking for a clean way to build the $connexionInfo array without casting $localDB or using a foreach loop.</p>

<pre><code>// This would be too easy if it worked 
$connexionInfo = array( "UID"      =&gt; $localDB-&gt;uid, 
                        "PWD"      =&gt; $localDB-&gt;pwd, 
                        "Database" =&gt; $localDB-&gt;DB
                       );

// tried using {} a few different ways, also does not seem to work
$connexionInfo = array( "UID" =&gt; {$localDB-&gt;uid}, 
                        "PWD" =&gt; {$localDB-&gt;pwd}, 
                         "Database"=&gt;  {$localDB-&gt;DB} 
                       );
</code></pre>

<p>I'm pretty sure there is a clean way to do this. Anyone?</p>

<p>UPdate:<br>
     // Contrary to what I posted above ... this DOES actually do what it's supposed to!</p>

<pre><code> $connectionInfo = array("UID" =&gt; $localDB-&gt;uid, "PWD" =&gt;$localDB-&gt;pwd, "Database"=&gt; $localDB-&gt;DB);
</code></pre>
