php: massive assignement
<p>I want to do a massive assignement of my protected vars, i used this code:</p>

<pre><code>protected $_productName = '';
protected $_price = 0;
protected $_categoyId = 0;  
 public function setAttributes($attributes)  
 {  
  foreach($attributes as $key =&gt; $val)  
  {
    $var = '_' . $key;
    $this-&gt;$var = $val;  
  }  
 }
</code></pre>

<p><code>$attributes = array('productName'=&gt;'some Product', 'price' =&gt; 10, 'categoryId' =&gt; 5)</code> for exapmle.  </p>

<p>the code above works for me but I feel that it's not clean. Is there any better solution to do that?  </p>

<p>thanx.</p>
