title: Converting a PHP array to class variables
body: <p>Simple question, how do I convert an associative array to variables in a class? I know there is casting to do an <code>(object) $myarray</code> or whatever it is, but that will create a new stdClass and doesn't help me much. Are there any easy one or two line methods to make each <code>$key =&gt; $value</code> pair in my array into a <code>$key = $value</code> variable for my class? I don't find it very logical to use a foreach loop for this, I'd be better off just converting it to a stdClass and storing that in a variable, wouldn't I?</p>
  
  <pre><code>class MyClass {
      var $myvar; // I want variables like this, so they can be references as $this-&gt;myvar
      function __construct($myarray) {
          // a function to put my array into variables
      }
  }
  </code></pre>